<!--{{{-->
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>
<!--}}}-->
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected{color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
.sparktick {background:[[ColorPalette::PrimaryDark]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0em 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0em 0em 0.5em;}
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0em 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0em 1em;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0em; font-size:.9em;}
.editorFooter .button {padding-top:0px; padding-bottom:0px;}

.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}

.sparkline {line-height:1em;}
.sparktick {outline:0;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
***/
/*{{{*/
body {font-size:0.8em;}
#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}
.subtitle {font-size:0.8em;}
.viewer table.listView {font-size:0.95em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
#displayArea {margin: 1em 1em 0em 1em;}
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
noscript {display:none;}
}
/*}}}*/
<!--{{{-->
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler > fields syncing permalink references jump'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>
<!--}}}-->
To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* MainMenu: The menu (usually on the left)
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
These InterfaceOptions for customising TiddlyWiki are saved in your browser

Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)

<<option txtUserName>>
<<option chkSaveBackups>> SaveBackups
<<option chkAutoSave>> AutoSave
<<option chkRegExpSearch>> RegExpSearch
<<option chkCaseSensitiveSearch>> CaseSensitiveSearch
<<option chkAnimate>> EnableAnimations

----
Also see AdvancedOptions
<<importTiddlers>>
In Socialtext Unplugged, the selected pages of your Socialtext workspace are displayed as individual "tiddlers" on the page. When the mouse passes over a tiddler a short toolbar menu appears at the top right. Use the commands here to manipulate that particular tiddler: notably closing and editting it. (You can double click on a tiddler as a shortcut to directly enter edit mode).

Over on the right hand side of the window are commands that affect the entire page, in particular "close all" which can be useful to clear the decks when many tiddlers are open at once.

The user is encouraged to ensure that they can SaveChanges before embarking on widespread editing.
Welcome to Socialtext Unplugged. This is a specially designed web page that you can use to view and edit your Socialtext content without having to be online to your Socialtext server.

There are three steps to using Socialtext Unplugged:
* First, learn how to SaveChanges to your local hard drive. This keeps your work safe even if you close your browser or have to reboot your computer
* Secondly, find out how to BrowseAndEdit your content while it is unplugged
* Thirdly, when you can reconnect to your Socialtext server, you can SyncChanges to save your unplugged changes to the server so that other people can see them too

You should also check your system meets the SystemRequirements.
Socialtext Unplugged lets you browse and edit your content while you're offline. When you make a change you need to SaveChanges to save the change to your local hard drive, before later performing a SyncChanges to synchronise the change back to the server.

The procedure for SaveChanges is slightly different for different browsers:
* SavingOnInternetExplorer
* SavingOnFireFox
* SavingOnSafari
* SavingOnOpera
You can save changes with any version of FireFox, and also many other browsers in the FireFox family, such as Camino on the Mac and MiniMo on mobile devices. The procedure is:
# Click the button labelled 'save changes' over in the right hand sidebar
# If prompted with an "Internet Security" dialog as follows, click the checkbox labelled "Remember this decision" and then the "Allow" button
## "A script from "file://" is requesting enhanced capabilities that are UNSAFE and could be used to compromise your machine or data..."
# You should then see a message at the top right of the window saying "Main TiddlyWiki file saved"
If you accidentally //deny// permission instead, you may need to UnravelFireFoxPermissions.
You can save changes with Internet Explorer versions 6 and 7, but not the earlier versions. The procedure is:
# Click the button labelled 'save changes' over in the right hand sidebar
# If prompted as follows, click "Yes":
## "An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?"
# You should then see a message at the top right of the window saying "Main TiddlyWiki file saved"
Note that there is currently [[a bug|http://trac.tiddlywiki.org/tiddlywiki/ticket/39]] that prevents Internet Explorer from saving correctly if you have specified a backup directory in AdvancedOptions.
To SaveChanges on Opera, see the instructions for using the TiddlySaver Java applet.
To SaveChanges on Safari, see the instructions for using the TiddlySaver Java applet.
<<search>><<closeAll>><<permaview>><<newTiddler 'New Tiddler' fields:'server.host:"https://saturn.ffzg.hr" server.workspace:"rot13" wikiformat:socialtext'>><<newJournal 'DD MMM YYYY' fields:'server.host:"https://saturn.ffzg.hr" server.workspace:"rot13" wikiformat:socialtext'>><<saveChanges>><<backstage sync>><<slider chkSliderOptionsPanel OptionsPanel 'options »' 'Change TiddlyWiki advanced options'>>
Dobrica Pavlinušić's random unstructured stuff
Socialtext Unplugged
https://saturn.ffzg.hr/rot13/
[[SocialtextScreenStyle]]
[[SocialtextStyleOverrides]]
[[Styles HorizontalMainMenu]]
<<sync>>
@@The user interface for synchronization is not finalized@@
To synchronize your changes back to the Socialtext server:
# click on [[Sync]] in the right-hand sidebar
<<tabs txtMoreTab Orphans 'Orphaned tiddlers' TabMoreOrphans Shadowed 'Shadowed tiddlers' TabMoreShadowed>>
Under FireFox, you can run into problems if you accidentally click 'Deny' on the permission request dialog, and have selected //Remember this decision//.

To reverse the effects, first locate the file {{{prefs.js}}} in your FireFox profile directory. Under Windows you'll find it at something like {{{C:\Documents and Settings\Jeremy\Application Data\Mozilla\Firefox\Profiles\o3dhupu6.default\prefs.js}}}, where {{{Jeremy}}} is the name of your windows profile and {{{o3dhupu6}}} will be a similar string of gobbledegook. On the Mac it'll be at {{{~/Library/Application Support/Firefox/Profiles/o3dhupu6.default/prefs.js}}} and on most versions of Linux, at {{{~/.mozilla/firefox/o3dhupu6.default/prefs.js}}}.

Open the file in a text editor and find the line {{{user_pref("capability.principal.codebase.p0.denied", "UniversalXPConnect");}}} and simply replace the word {{{denied}}} with {{{granted}}}.
//(Thanks to JonScully for figuring out this fix)//
<!--{{{-->
<div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler references > fields syncing jump'></div>
<div class='workspace' id='st-page-wiki-title' macro='view socialtext.workspace'></div>
<div class='title' id='st-page-titletext' macro='view title'></div>
<div class='subtitle'>
Created on <span macro='view created date [[MMM DD, 0hh:0mm]]'></span>.
Updated by <span macro='view modifier link'></span>
on <span macro='view modified date [[MMM DD, 0hh:0mm]]'></span></div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></span></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
/***
To use, add {{{[[Styles HorizontalMainMenu]]}}} to your StyleSheet tiddler.
See http://www.w3schools.com/css/css_colors.asp for a color chart.
***/
/*{{{*/
#mainMenu {position:relative;left:auto;width:auto;text-align:left;line-height:normal;padding 0em 1em 0em 1em;font-size:normal;}
#mainMenu br {display:none;}
#mainMenu {background:#336699;}
#mainMenu {padding:2px;}
#mainMenu .button, #mainMenu .tiddlyLink {padding-left:0.5em;padding-right:0.5em;color:white;font-size:115%;}

#displayArea {
	margin-top:0;margin-right:20em;margin-bottom:0;margin-left:1em;
	padding-top:.1em;padding-bottom:.1em;
}
/*}}}*/
|''Type:''|socialtext|
|''URL:''|https://saturn.ffzg.hr |
|''Workspace:''|rot13|
|''WorkspaceList:''||
|''Description:''|Dobrica Pavlinušić's random unstructured stuff|
The TiddlySaver Java applet allows TiddlyWiki from a {{{file://}}} URL to save changes Safari, Opera and other browsers.

It is a small file named [["TiddlySaver.jar"|TiddlySaver.jar]] that must be placed in the same directory as your TiddlyWiki file. Before you can use it, you need to give it the necessary privileges by editting your {{{.java.policy}}} file.

For Windows, the file will be at {{{C:\Documents and Settings\your-user-name\.java.policy}}}. Add the following lines (substituting the directory of your TiddlyWiki file as appropriate):
{{{
grant codeBase "file:${user.home}/My Documents/tiddlywiki-folder/*" {
  permission java.io.FilePermission "${user.home}${/}My Documents${/}tiddlywiki-folder${/}*", "read,write";
};
}}}
On Mac OS X, the file is found at {{{/Users/your-user-name/.java.policy}}}:
{{{
grant codeBase "file:${user.home}/Documents/tiddlywiki-folder/*" {
  permission java.io.FilePermission "${user.home}${/}Documents${/}tiddlywiki-folder${/}*", "read,write";
};
}}}
It can be tricky creating files whose name starts with a period, so you can use this [[pre-built .java.policy file|.java.policy]]. The same file is suitable for Macs too, just edit it and delete the "My " bit, leaving just "Documents". Make sure you save it in the right place for each operating system!

If you have trouble setting up the permissions correctly, you can try granting broader permissions to the applet like this:

{{{
grant codeBase "file://localhost/home/users/Desktop/
TiddlySaver.jar"
 { permission java.security.AllPermission; };
}}}

Note that there is currently [[a bug|http://trac.tiddlywiki.org/ticket/172]] that prevents TiddlySaver from working if you have specified a backup directory in AdvancedOptions.
/***
|''Name:''|SocialtextLocaleOverrides|
|''Description:''|Text changes for Socialtext|
***/

//{{{
merge(config.views.wikified.tag,{
	labelNoTags: "No Tags",
	labelTags: "Tags"});

merge(config.commands.references,{
	text: "incoming links",
	tooltip: "Show tiddlers that link to this one",
	popupNone: "No incoming links"});
//}}}
/***
|''Name:''|SocialtextTweaksPlugin|
|''Description:''|Allows changes to be synchronised with a Socialtext server|
|''Source:''|http://stunplugged.tiddlywiki.com/#SocialtextTweaksPlugin|
|''Author:''|JeremyRuston (jeremy (at) osmosoft (dot) com)|
|''Version:''|1.0.2|
|''Date:''|Jun 15, 2006|
|''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev|
|''License:''|[[BSD open source license]]|
|''~CoreVersion:''|2.2|

Make minor configuration tweaks specific to Socialtext Unplugged
***/

//{{{
// Ensure that the SocialtextTweaksPlugin is only installed once.
if(!version.extensions.SocialtextTweaksPlugin) {
version.extensions.SocialtextTweaksPlugin = {installed:true};
// Check version number of core code
if(version.major < 2 || (version.major == 2 && version.minor < 2))
	{alertAndThrow("SocialtextTweaksPlugin requires TiddlyWiki 2.2 or later.");}

merge(config.defaultCustomFields,{
	wikiformat:'socialtext',
	'server.host':'https://saturn.ffzg.hr'
});

config.options.chkSinglePageMode = true;
config.options.chkEnableAnimations = true;

} // end of "install only once"
//}}}
/***
|''Name:''|SocialtextFormatterPlugin|
|''Description:''|Allows Tiddlers to use [[Socialtext|http://www.socialtext.com/]] text formatting|
|''Author:''|Martin Budden (mjbudden (at) gmail (dot) com)|
|''Source:''|http://www.martinswiki.com/#SocialtextFormatterPlugin|
|''CodeRepository:''|http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/formatters/SocialtextFormatterPlugin.js|
|''Version:''|0.9.4|
|''Date:''|Jan 21, 2007|
|''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev|
|''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|''~CoreVersion:''|2.1.0|

This is the SocialtextFormatterPlugin, which allows you to insert Socialtext formated text into a TiddlyWiki.

The aim is not to fully emulate Socialtext, but to allow you to work with Socialtext content off-line and then resync the content with your Socialtext wiki later on, with the expectation that only minor edits will be required.

To use Socialtext format in a Tiddler, tag the Tiddler with SocialtextFormat or set the tiddler's {{{wikiformat}}} extended field to {{{socialtext}}}

Please report any defects you find at http://groups.google.co.uk/group/TiddlyWikiDev
***/

//{{{
// Ensure that the SocialtextFormatter Plugin is only installed once.
if(!version.extensions.SocialtextFormatterPlugin) {
version.extensions.SocialtextFormatterPlugin = {installed:true};

if(version.major < 2 || (version.major == 2 && version.minor < 1))
	{alertAndThrow('SocialtextFormatterPlugin requires TiddlyWiki 2.1 or later.');}

SocialtextFormatter = {}; // 'namespace' for local functions

wikify = function(source,output,highlightRegExp,tiddler)
{
	if(source && source != '') {
		var w = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
		var out = output;
		if(tiddler && (tiddler.isTagged(config.parsers.socialtextFormatter.formatTag) || (tiddler.fields.wikiformat==config.parsers.socialtextFormatter.format)) ) {
			var d1 = createTiddlyElement(output,'div','content-display-body','content-section-visible');
			var d2 = createTiddlyElement(d1,'div','wikipage');
			out = createTiddlyElement(d2,'div',null,'wiki');
		}
		var time1,time0 = new Date();
		w.subWikifyUnterm(out);
		if(tiddler && config.options.chkDisplayInstrumentation) {
			time1 = new Date();
			var t = tiddler ? tiddler.title : source.substr(0,10);
			displayMessage("Wikify '"+t+"' in " + (time1-time0) + " ms");
		}
	}
};

stDebug = function(out,str)
{
	createTiddlyText(out,str.replace(/\n/mg,'\\n').replace(/\r/mg,'RR'));
	createTiddlyElement(out,'br');
};

SocialtextFormatter.Tiddler_changed = Tiddler.prototype.changed;
Tiddler.prototype.changed = function()
{
	if((this.fields.wikiformat==config.parsers.socialtextFormatter.format) || this.isTagged(config.parsers.socialtextFormatter.formatTag)) {
		// update the links array, by checking for Socialtext format links
		this.links = [];
		var tiddlerLinkRegExp = /(?:\"(.*?)\" ?)?\[([^\]]*?)\]/mg;
		tiddlerLinkRegExp.lastIndex = 0;
		var match = tiddlerLinkRegExp.exec(this.text);
		while(match) {
			var link = match[2];
			this.links.pushUnique(link);
			match = tiddlerLinkRegExp.exec(this.text);
		}
	}/* else {
		return SocialtextFormatter.Tiddler_changed.apply(this,arguments);
	}*/
	this.linksUpdated = true;
};

SocialtextFormatter.wafl = function(w)
{
	this.lookaheadRegExp.lastIndex = w.matchStart;
	var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
	if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
		var lm2 = lookaheadMatch[2];
		switch(lookaheadMatch[1]) {
		case 'image':
			var img = createTiddlyElement(w.output,'img');
			img.src = w.tiddler.title + '/' + lm2;
			createTiddlyText(img,lm2);
			break;
		case 'file':
			var s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			var a = createTiddlyElement(s,'a');
			a.href = w.tiddler.title + '/' + lm2;
			createTiddlyText(a,lm2);
			break;
		case 'link':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createTiddlyElement(s,'a');
			var t = w.tiddler ? w.tiddler.title + ':' : '';
			a.setAttribute('href','#' + t + lm2);
			a.title = 'section link';
			createTiddlyText(a,lm2);
			break;
		case 'weblog':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			var text = lm2;
			var link = 'Weblog: ' + lm2;
			createTiddlyText(createTiddlyLink(s,link,false,null,w.isStatic),text);
			break;
		case 'section':
			a = createTiddlyElement(w.output,'a');// drop anchor
			t = w.tiddler ? w.tiddler.title + ':' : '';
			a.setAttribute('name',t + lm2);
			break;
		case 'date':
			createTiddlyText(w.output,lm2);
			break;
		case 'user':
			var oldSource = w.source;
			w.source = lm2;
			w.nextMatch = 0;
			w.subWikifyUnterm(w.output);
			w.source = oldSource;
			break;
// Shortcut expansions - not strictly syntax
		case 'google':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'http://www.google.com/search?q='+lm2);
			createTiddlyText(a,lm2);
			break;
		case 'fedex':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'http://www.fedex.com/Tracking?tracknumbers='+lm2);
			createTiddlyText(a,lm2);
			break;
		case 'map':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'http://maps.google.com/maps?q='+lm2);
			createTiddlyText(a,lm2);
			break;
		case 'wikipedia':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'http://en.wikipedia.org/wiki/'+lm2);
			createTiddlyText(a,lm2);
			break;
		case 'rt':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'http://rt.socialtext.net/Ticket/Display.html?id='+lm2);
			createTiddlyText(a,lm2);
			break;
		case 'stcal':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'https://calendar.socialtext.net:445/view_t.php?timeb=1&id=3&date='+lm2);
			createTiddlyText(a,lm2);
			break;
		case 'svn':
			s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
			a = createExternalLink(s,'https://repo.socialtext.net/listing.php?rev='+lm2+'sc=1');
			createTiddlyText(a,lm2);
			break;
		default:
			w.outputText(w.output,w.matchStart,w.nextMatch);
			return;
		}
		w.nextMatch = this.lookaheadRegExp.lastIndex;
	} else {
		w.outputText(w.output,w.matchStart,w.nextMatch);
	}
};

SocialtextFormatter.presence = function(w)
{
	this.lookaheadRegExp.lastIndex = w.matchStart;
	var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
	if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
		var p = lookaheadMatch[1];
		var text = lookaheadMatch[2];
		var link;
		var src;
		if(p=='aim') {
			link = 'aim:goim?screenname=' + text + '&message=hello';
			src = 'http://big.oscar.aol.com/sleepleft?on_url=http://www.aim.com/remote/gr/MNB_online.gif&amp;off_url=http://www.aim.com/remote/gr/MNB_offline.gif';
		} else if(p=='yahoo'||p=='ymsgr') {
			link = 'ymsgr:sendIM?'+text;
			src = 'http://opi.yahoo.com/online?u=chrislondonbridge&f=.gif';
		} else if(p=='skype'||p=='callto') {
			link = 'callto:'+text;
			src = 'http://goodies.skype.com/graphics/skypeme_btn_small_green.gif';
		} else if(p=='asap') {
			link = 'http://asap2.convoq.com/AsapLinks/Meet.aspx?l='+text;
			src = 'http://asap2.convoq.com/AsapLinks/Presence.aspx?l='+text;
		}
		var s = createTiddlyElement(w.output,'span',null,'nlw_phrase');
		var a = createExternalLink(s,link);
		var img = createTiddlyElement(a,'img');
		createTiddlyText(a,text);
		img.src = src;
		img.border='0';
		img.alt = '(' + lookaheadMatch[1] + ')';
		if(p=='aim') {
			img.width='11'; img.height='13';
		}
		w.nextMatch = this.lookaheadRegExp.lastIndex;
	}
};

config.formatterHelpers.singleCharFormat = function(w)
{
	this.lookaheadRegExp.lastIndex = w.matchStart;
	var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
	if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[0].substr(lookaheadMatch[0].length-2,1) != ' ') {
		w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
	} else {
		w.outputText(w.output,w.matchStart,w.nextMatch);
	}
};

config.socialtext = {};
config.socialtext.formatters = [
{
	name: 'socialtextHeading',
	match: '^\\^{1,6} ?',
	termRegExp: /(\n+)/mg,
	handler: function(w)
	{
		var len = w.matchText.trim().length;
		var e = createTiddlyElement(w.output,'h' + len);
		var a = createTiddlyElement(e,'a');// drop anchor
		var t = w.tiddler ? w.tiddler.title + ':' : '';
		len = w.source.substr(w.nextMatch).indexOf('\n');
		a.setAttribute('name',t+w.source.substr(w.nextMatch,len));
		w.subWikifyTerm(e,this.termRegExp);
	}
},

{
	name: 'socialtextTable',
	match: '^\\|(?:(?:.|\n)*)\\|$',
	lookaheadRegExp: /^\|(?:(?:.|\n)*)\|$/mg,
	cellRegExp: /(?:\|(?:[^\|]*)\|)(\n|$)?/mg,
	cellTermRegExp: /((?:\x20*)\|)/mg,
	handler: function(w)
	{
		var table = createTiddlyElement(w.output,'table');
		var rowContainer = createTiddlyElement(table,'tbody');
		var prevColumns = [];
		w.nextMatch = w.matchStart;
		this.lookaheadRegExp.lastIndex = w.nextMatch;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
			var r = this.rowHandler(w,createTiddlyElement(rowContainer,'tr'),prevColumns);
			if(!r) {
				w.nextMatch++;
				break;
			}
			this.lookaheadRegExp.lastIndex = w.nextMatch;
			lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		}
	},
	rowHandler: function(w,e,prevColumns)
	{
		this.cellRegExp.lastIndex = w.nextMatch;
		var cellMatch = this.cellRegExp.exec(w.source);
		while(cellMatch && cellMatch.index == w.nextMatch) {
			w.nextMatch++;
			var cell = createTiddlyElement(e,'td');
			w.subWikifyTerm(cell,this.cellTermRegExp);
			if(cellMatch[1]) {
				// End of row
				w.nextMatch = this.cellRegExp.lastIndex;
				return true;
			}
			// Cell
			w.nextMatch--;
			this.cellRegExp.lastIndex = w.nextMatch;
			cellMatch = this.cellRegExp.exec(w.source);
		}
		return false;
	}
},

{
	name: 'socialtextList',
	match: '^[\\*#]+ ',
	lookaheadRegExp: /^([\*#])+ /mg,
	termRegExp: /(\n+)/mg,
	handler: function(w)
	{
		var stack = [w.output];
		var currLevel = 0, currType = null;
		var itemType = 'li';
		w.nextMatch = w.matchStart;
		this.lookaheadRegExp.lastIndex = w.nextMatch;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
			var listType = lookaheadMatch[1] == '*' ? 'ul' : 'ol';
			var listLevel = lookaheadMatch[0].length;
			w.nextMatch += listLevel;
			if(listLevel > currLevel) {
				for(var i=currLevel; i<listLevel; i++) {
					stack.push(createTiddlyElement(stack[stack.length-1],listType));
				}
			} else if(listLevel < currLevel) {
				for(i=currLevel; i>listLevel; i--) {
					stack.pop();
				}
			} else if(listLevel == currLevel && listType != currType) {
				stack.pop();
				stack.push(createTiddlyElement(stack[stack.length-1],listType));
			}
			currLevel = listLevel;
			currType = listType;
			var e = createTiddlyElement(stack[stack.length-1],itemType);
			w.subWikifyTerm(e,this.termRegExp);
			this.lookaheadRegExp.lastIndex = w.nextMatch;
			lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		}
	}
},

{
	name: 'socialtextQuoteByLine',
	match: '^>+',
	lookaheadRegExp: /^>+/mg,
	termRegExp: /(\n)/mg,
	element: 'blockquote',
	handler: function(w)
	{
		var stack = [w.output];
		var currLevel = 0;
		var newLevel = w.matchLength;
		var i;
		do {
			if(newLevel > currLevel) {
				for(i=currLevel; i<newLevel; i++) {
					stack.push(createTiddlyElement(stack[stack.length-1],this.element));
				}
			} else if(newLevel < currLevel) {
				for(i=currLevel; i>newLevel; i--) {
					stack.pop();
				}
			}
			currLevel = newLevel;
			w.subWikifyTerm(stack[stack.length-1],this.termRegExp);
			createTiddlyElement(stack[stack.length-1],'br');
			this.lookaheadRegExp.lastIndex = w.nextMatch;
			var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
			var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
			if(matched) {
				newLevel = lookaheadMatch[0].length;
				w.nextMatch += newLevel;
			}
		} while(matched);
	}
},

{
	name: 'socialtextRule',
	match: '^----+$\\n+',
	handler: function(w)
	{
		createTiddlyElement(w.output,'hr');
	}
},

{
	name: 'socialtextPreformatted',
	match: '^\\.pre\\s*\\n',
	lookaheadRegExp: /^.pre\s*\n((?:.|\n)*?)\n.pre\s*\n/mg,
	element: 'pre',
	handler: config.formatterHelpers.enclosedTextHelper
},

{
	name: 'socialtextHtml',
	match: '^\\.html',
	lookaheadRegExp: /\.html((?:.|\n)*?)\.html/mg,
	handler: function(w)
	{
		this.lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			createTiddlyElement(w.output,'span').innerHTML = lookaheadMatch[1];
			w.nextMatch = this.lookaheadRegExp.lastIndex;
		}
	}
},

{
	name: 'macro',
	match: '<<',
	lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
	handler: function(w)
	{
		this.lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) {
			w.nextMatch = this.lookaheadRegExp.lastIndex;
			invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
		}
	}
},

{
	name: 'socialtextExplicitLink',
	match: '(?:".*?" ?)?\\[',
	lookaheadRegExp: /(?:\"(.*?)\" ?)?\[([^\]]*?)\]/mg,
	handler: function(w)
	{
		this.lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			var link = lookaheadMatch[2];
			var text = lookaheadMatch[1] ? lookaheadMatch[1] : link;
			createTiddlyText(createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler),text);
			w.nextMatch = this.lookaheadRegExp.lastIndex;
		}
	}
},

{
	name: 'socialtextExternalLink',
	match: '(?:".*?" ?)?<[a-z]{2,8}:',
	lookaheadRegExp: /(?:\"(.*?)\" ?)?<([a-z]{2,8}:.*?)>/mg,
	imgRegExp: /\.(?:gif|ico|jpg|png)/g,
	handler: function(w)
	{
		this.lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			var link = lookaheadMatch[2];
			var text = lookaheadMatch[1] ? lookaheadMatch[1] : link;
			this.imgRegExp.lastIndex = 0;
			if(this.imgRegExp.exec(link)) {
				var img = createTiddlyElement(w.output,'img');
				if(lookaheadMatch[1]) {
					img.title = text;
				}
				img.alt = text;
				img.src = link;
			} else {
				createTiddlyText(createExternalLink(w.output,link),text);
			}
			w.nextMatch = this.lookaheadRegExp.lastIndex;
		}
	}
},

{
	name: 'socialtextUrlLink',
	match: config.textPrimitives.urlPattern,
	handler: function(w)
	{
		w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
	}
},

{
	name: 'socialtextBold',
	match: '\\*(?![\\s\\*])',
	lookaheadRegExp: /\*(?!\s)(?:.*?)(?!\s)\*(?=[$\s\|\._\-,])/mg,
	termRegExp: /((?!\s)\*(?=[$\s\|\.\-_,]))/mg,
	element: 'strong',
	handler: config.formatterHelpers.singleCharFormat
},

{
	name: 'socialtextItalic',
	match: '_(?![\\s_])',
	lookaheadRegExp: /_(?!\s)(?:.*?)(?!\s)_(?=[$\s\|\.\*\-,])/mg,
	termRegExp: /((?!\s)_(?=[$\s\|\.\*\-,]))/mg,
	element: 'em',
	handler: config.formatterHelpers.singleCharFormat
},

{
	name: 'socialtextStrike',
	match: '-(?![\\s\\-])',
	lookaheadRegExp: /-(?!\s)(?:.*?)(?!\s)-(?=[$\s\|\.\*_,])/mg,
	termRegExp: /((?!\s)-(?=[$\s\|\.\*_,]))/mg,
	element: 'del',
	handler: config.formatterHelpers.singleCharFormat
},

{
	name: 'socialtextMonoSpaced',
	match: '`(?![\\s`])',
	lookaheadRegExp: /`(?!\s)(?:.*?)(?!\s)`(?=[$\s\.\*\-_,])/mg,
	termRegExp: /((?!\s)`(?=[$\s\.\*\-_,]))/mg,
	element: 'tt',
	handler: config.formatterHelpers.singleCharFormat
},

{
	name: 'socialtextParagraph',
	match: '\\n{2,}',
	handler: function(w)
	{
		createTiddlyElement(w.output,'p');
	}
},

{
	name: 'socialtextLineBreak',
	match: '\\n',
	handler: function(w)
	{
		createTiddlyElement(w.output,'br');
	}
},

{
	name: 'socialtextNoWiki',
	match: '\\{\\{',
	lookaheadRegExp: /\{\{((?:.|\n)*?)\}\}/mg,
	element: 'span',
	handler: config.formatterHelpers.enclosedTextHelper
},

{
	name: 'socialtextTrademark',
	match: '\\{tm\\}',
	handler: function(w)
	{
		createTiddlyElement(w.output,'span').innerHTML = '&trade;';
	}
},

{
	name: 'socialtextWafl',
	match: '\\{(?:[a-z]{2,16}): ?.*?\\}',
	lookaheadRegExp: /\{([a-z]{2,16}): ?(.*?)\}/mg,
	handler: SocialtextFormatter.wafl
},

{
	name: 'socialtextPresence',
	match: '(?:aim|yahoo|ymsgr|skype|callto|asap):\\w+',
	lookaheadRegExp: /(aim|yahoo|ymsgr|skype|callto|asap):(\w+)/mg,
	handler: SocialtextFormatter.presence
},

{
	name: 'socialtextMailTo',
	match: '[\\w\.]+@[\\w]+\.[\\w\.]+',
	lookaheadRegExp: /([\w\.]+@[\w]+\.[\w\.]+)/mg,
	handler: function(w)
	{
		this.lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			var text = lookaheadMatch[1];
			createTiddlyText(createExternalLink(w.output,'mailto:'+text),text);
			w.nextMatch = this.lookaheadRegExp.lastIndex;
		}
	}
},

{
	name: 'socialtextHtmlEntitiesEncoding',
	match: '&#?[a-zA-Z0-9]{2,8};',
	handler: function(w)
	{
		createTiddlyElement(w.output,'span').innerHTML = w.matchText;
	}
}
];

config.parsers.socialtextFormatter = new Formatter(config.socialtext.formatters);
config.parsers.socialtextFormatter.format = 'socialtext';
config.parsers.socialtextFormatter.formatTag = 'SocialtextFormat';

} // end of 'install only once'
//}}}
/***
|''Name:''|SocialtextAdaptorPlugin|
|''Description:''|Adaptor for moving and converting data to and from Socialtext Wikis|
|''Author:''|Martin Budden (mjbudden (at) gmail (dot) com) and JeremyRuston (jeremy (at) osmosoft (dot) com)|
|''Source:''|http://www.martinswiki.com/#SocialtextAdaptorPlugin|
|''CodeRepository:''|http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/adaptors/SocialtextAdaptorPlugin.js|
|''Version:''|0.5.1|
|''Date:''|Feb 25, 2007|
|''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev|
|''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|''~CoreVersion:''|2.2.0|

Socialtext REST documentation is at:
http://www.eu.socialtext.net/st-rest-docs/index.cgi?socialtext_rest_documentation

***/

//{{{
if(!version.extensions.SocialtextAdaptorPlugin) {
version.extensions.SocialtextAdaptorPlugin = {installed:true};

function SocialtextAdaptor()
{
	this.host = null;
	this.workspace = null;
	return this;
}

SocialtextAdaptor.mimeType = 'text/x.socialtext-wiki';
SocialtextAdaptor.serverType = 'socialtext';
SocialtextAdaptor.serverParsingErrorMessage = "Error parsing result from server";
SocialtextAdaptor.errorInFunctionMessage = "Error in function SocialtextAdaptor.%0";

SocialtextAdaptor.prototype.setContext = function(context,userParams,callback)
{
	if(!context) context = {};
	context.userParams = userParams;
	if(callback) context.callback = callback;
	context.adaptor = this;
	if(!context.host)
		context.host = this.host;
	if(!context.workspace && this.workspace)
		context.workspace = this.workspace;
	return context;
};

SocialtextAdaptor.doHttpGET = function(uri,callback,params,headers,data,contentType,username,password)
{
	return doHttp('GET',uri,data,contentType,username,password,callback,params,headers);
};

SocialtextAdaptor.doHttpPOST = function(uri,callback,params,headers,data,contentType,username,password)
{
	return doHttp('POST',uri,data,contentType,username,password,callback,params,headers);
};

SocialtextAdaptor.fullHostName = function(host)
{
	if(!host)
		return '';
	if(!host.match(/:\/\//))
		host = 'http://' + host;
	if(host.substr(host.length-1) != '/')
		host = host + '/';
	return host;
};

SocialtextAdaptor.minHostName = function(host)
{
	return host ? host.replace(/^http:\/\//,'').replace(/\/$/,'') : '';
};

// Convert a page title to the normalized form used in uris
SocialtextAdaptor.normalizedTitle = function(title)
{
	var n = title.toLowerCase();
	n = n.replace(/\s/g,'_').replace(/\//g,'_').replace(/\./g,'_').replace(/:/g,'').replace(/\?/g,'');
	if(n.charAt(0)=='_')
		n = n.substr(1);
	return String(n);
};

// Convert a Socialtext date in YYYY-MM-DD hh:mm format into a JavaScript Date object
SocialtextAdaptor.dateFromEditTime = function(editTime)
{
	var dt = editTime;
	return new Date(Date.UTC(dt.substr(0,4),dt.substr(5,2)-1,dt.substr(8,2),dt.substr(11,2),dt.substr(14,2)));
};

SocialtextAdaptor.prototype.openHost = function(host,context,userParams,callback)
{
	this.host = SocialtextAdaptor.fullHostName(host);
	context = this.setContext(context,userParams,callback);
	if(context.callback) {
		context.status = true;
		window.setTimeout(function() {callback(context,userParams);},0);
	}
	return true;
};

SocialtextAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)
{
	this.workspace = workspace;
	context = this.setContext(context,userParams,callback);
	if(context.callback) {
		context.status = true;
		window.setTimeout(function() {callback(context,userParams);},0);
	}
	return true;
};


SocialtextAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
{
	context = this.setContext(context,userParams,callback);
	var uriTemplate = '%0data/workspaces';
	var uri = uriTemplate.format([context.host]);
	var req = SocialtextAdaptor.doHttpGET(uri,SocialtextAdaptor.getWorkspaceListCallback,context,{'accept':'application/json'});
	return typeof req == 'string' ? req : true;
};

SocialtextAdaptor.getWorkspaceListCallback = function(status,context,responseText,uri,xhr)
{
	context.status = false;
	context.statusText = SocialtextAdaptor.errorInFunctionMessage.format(['getWorkspaceListCallback']);
	if(status) {
		try {
			eval('var info=' + responseText);
		} catch (ex) {
			context.statusText = exceptionText(ex,SocialtextAdaptor.serverParsingErrorMessage);
			if(context.callback)
				context.callback(context,context.userParams);
			return;
		}
		var list = [];
		for(var i=0; i<info.length; i++) {
			var item = {
				title:info[i].title,
				name:info[i].name,
				modified:SocialtextAdaptor.dateFromEditTime(info[i].modified_time)
				};
			list.push(item);
		}
		context.workspaces = list;
		context.status = true;
	} else {
		context.statusText = xhr.statusText;
	}
	if(context.callback)
		context.callback(context,context.userParams);
};

SocialtextAdaptor.prototype.getTiddlerList = function(context,userParams,callback)
{
	context = this.setContext(context,userParams,callback);
	var uriTemplate = '%0data/workspaces/%1/pages?order=newest';//!! ? or ;
	var uri = uriTemplate.format([context.host,context.workspace]);
	var req = SocialtextAdaptor.doHttpGET(uri,SocialtextAdaptor.getTiddlerListCallback,context,{'accept':'application/json'});
	return typeof req == 'string' ? req : true;
};


SocialtextAdaptor.getTiddlerListCallback = function(status,context,responseText,uri,xhr)
{
	context.status = false;
	context.statusText = SocialtextAdaptor.errorInFunctionMessage.format(['getTiddlerListCallback']);
	if(status) {
		try {
			eval('var info=' + responseText);
		} catch (ex) {
			context.statusText = exceptionText(ex,SocialtextAdaptor.serverParsingErrorMessage);
			if(context.callback)
				context.callback(context,context.userParams);
			return;
		}
		var list = [];
		for(var i=0; i<info.length; i++) {
			var tiddler = new Tiddler(info[i].name);
			tiddler.modified = SocialtextAdaptor.dateFromEditTime(info[i].last_edit_time);
			tiddler.modifier = info[i].last_editor;
			tiddler.tags = info[i].tags;
			tiddler.fields['server.page.id'] = info[i].page_id;
			tiddler.fields['server.page.name'] = info[i].name;
			tiddler.fields['server.page.revision'] = String(info[i].revision_id);
			list.push(tiddler);
		}
		context.tiddlers = list;
		context.status = true;
	} else {
		context.statusText = xhr.statusText;
	}
	if(context.callback)
		context.callback(context,context.userParams);
};

SocialtextAdaptor.prototype.generateTiddlerInfo = function(tiddler)
{
	var info = {};
	var host = this && this.host ? this.host : SocialtextAdaptor.fullHostName(tiddler.fields['server.host']);
	var workspace = this && this.workspace ? this.workspace : tiddler.fields['server.workspace'];
	uriTemplate = '%0%1/index.cgi?%2';
	info.uri = uriTemplate.format([host,workspace,SocialtextAdaptor.normalizedTitle(tiddler.title)]);
	return info;
};

SocialtextAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
{
	return this.getTiddlerRevision(title,null,context,userParams,callback);
};

SocialtextAdaptor.prototype.getTiddlerRevision = function(title,revision,context,userParams,callback)
{
	context = this.setContext(context,userParams,callback);

	// request the page in json format to get the page attributes
	if(revision) {
		var uriTemplate = '%0data/workspaces/%1/pages/%2/revisions/%3';
		context.revision = revision;
	} else {
		uriTemplate = '%0data/workspaces/%1/pages/%2';
		context.revision = null;
	}
	uri = uriTemplate.format([context.host,context.workspace,SocialtextAdaptor.normalizedTitle(title),revision]);

	context.tiddler = new Tiddler(title);
	context.tiddler.fields.wikiformat = 'socialtext';
	context.tiddler.fields['server.host'] = SocialtextAdaptor.minHostName(context.host);
	context.tiddler.fields['server.workspace'] = context.workspace;
	var req = SocialtextAdaptor.doHttpGET(uri,SocialtextAdaptor.getTiddlerCallback,context,{'accept':'application/json'});
	return typeof req == 'string' ? req : true;
};


SocialtextAdaptor.getTiddlerCallback = function(status,context,responseText,uri,xhr)
{
	context.status = false;
	context.statusText = SocialtextAdaptor.errorInFunctionMessage.format(['getTiddlerCallback']);
	if(status) {
		try {
			eval('var info=' + responseText);
			context.tiddler.tags = info.tags;
			context.tiddler.fields['server.page.id'] = info.page_id;
			context.tiddler.fields['server.page.name'] = info.name;
			context.tiddler.fields['server.page.revision'] = String(info.revision_id);
			context.tiddler.modifier = info.last_editor;
			context.tiddler.modified = SocialtextAdaptor.dateFromEditTime(info.last_edit_time);
		} catch (ex) {
			context.statusText = exceptionText(ex,SocialtextAdaptor.serverParsingErrorMessage);
			if(context.callback)
				context.callback(context,context.userParams);
			return;
		}
		context.status = true;
	} else {
		context.statusText = xhr.statusText;
		if(context.callback)
			context.callback(context,context.userParams);
		return;
	}
	var uriTemplate = context.revision ? '%0data/workspaces/%1/pages/%2/revisions/%3' : '%0data/workspaces/%1/pages/%2';
	var host = SocialtextAdaptor.fullHostName(context.tiddler.fields['server.host']);
	var workspace = context.workspace ? context.workspace : context.tiddler.fields['server.workspace'];
	uri = uriTemplate.format([host,workspace,SocialtextAdaptor.normalizedTitle(context.tiddler.title),context.revision]);
	var req = SocialtextAdaptor.doHttpGET(uri,SocialtextAdaptor.getTiddlerCallback2,context,{'accept':SocialtextAdaptor.mimeType});
};

SocialtextAdaptor.getTiddlerCallback2 = function(status,context,responseText,uri,xhr)
{
	context.tiddler.text = responseText;
	if(status) {
		context.status = true;
	} else {
		context.status = false;
		context.statusText = xhr.statusText;
	}
	if(context.callback)
		context.callback(context,context.userParams);
};

SocialtextAdaptor.prototype.getTiddlerRevisionList = function(title,limit,context,userParams,callback)
{
	context = this.setContext(context,userParams,callback);

	var uriTemplate = '%0data/workspaces/%1/pages/%2/revisions?accept=application/json';
	if(!limit)
		limit = 5;
	var uri = uriTemplate.format([context.host,context.workspace,SocialtextAdaptor.normalizedTitle(title),limit]);

	var req = SocialtextAdaptor.doHttpGET(uri,SocialtextAdaptor.getTiddlerRevisionListCallback,context);
	return typeof req == 'string' ? req : true;
};

SocialtextAdaptor.getTiddlerRevisionListCallback = function(status,context,responseText,uri,xhr)
{
	context.status = false;
	if(status) {
		var content = null;
		try {
			eval('var info=' + responseText);
		} catch (ex) {
			context.statusText = exceptionText(ex,SocialtextAdaptor.serverParsingErrorMessage);
			if(context.callback)
				context.callback(context,context.userParams);
			return;
		}
		list = [];
		for(var i=0; i<info.length; i++) {
			var tiddler = new Tiddler(info[i].name);
			tiddler.modified = SocialtextAdaptor.dateFromEditTime(info[i].last_edit_time);
			tiddler.modifier = info[i].last_editor;
			tiddler.tags = info[i].tags;
			tiddler.fields['server.page.id'] = info[i].page_id;
			tiddler.fields['server.page.name'] = info[i].name;
			tiddler.fields['server.page.revision'] = info[i].revision_id;
			list.push(tiddler);
		}
		var sortField = 'server.page.revision';
		list.sort(function(a,b) {return a.fields[sortField] < b.fields[sortField] ? +1 : (a.fields[sortField] == b.fields[sortField] ? 0 : -1);});
		context.revisions = list;
		context.status = true;
	} else {
		context.statusText = xhr.statusText;
	}
	if(context.callback)
		context.callback(context,context.userParams);
};

SocialtextAdaptor.prototype.putTiddler = function(tiddler,context,userParams,callback)
{
	context = this.setContext(context,userParams,callback);
	context.tiddler = tiddler;
	context.title = tiddler.title;
	var uriTemplate = '%0data/workspaces/%1/pages/%2';
	var host = context.host ? context.host : SocialtextAdaptor.fullHostName(tiddler.fields['server.host']);
	var workspace = context.workspace ? context.workspace : tiddler.fields['server.workspace'];
	var uri = uriTemplate.format([host,workspace,tiddler.title,tiddler.text]);
	//var req = doHttp('POST',uri,tiddler.text,SocialtextAdaptor.mimeType,null,null,SocialtextAdaptor.putTiddlerCallback,context,{"X-Http-Method": "PUT"});
	var req = SocialtextAdaptor.doHttpPOST(uri,SocialtextAdaptor.putTiddlerCallback,context,{"X-Http-Method": "PUT"},tiddler.text,SocialtextAdaptor.mimeType);
	return typeof req == 'string' ? req : true;
};

SocialtextAdaptor.putTiddlerCallback = function(status,context,responseText,uri,xhr)
{
	if(status) {
		context.status = true;
	} else {
		context.status = false;
		context.statusText = xhr.statusText;
	}
	if(context.callback)
		context.callback(context,context.userParams);
};

SocialtextAdaptor.prototype.close = function()
{
	return true;
};

config.adaptors[SocialtextAdaptor.serverType] = SocialtextAdaptor;
} //# end of 'install only once'
//}}}
/***
SocialtextStyleOverrides
***/

/*{{{*/
.headerShadow {padding: 2em 0em .5em 1em;}
.headerForeground {padding: 2em 0em .5em 1em;}

#st-page-wiki-title {
	font-size: 80%;
}
.subtitle {
	font-style: italic;
	font-size 80%;
}

/* from #st-tags */
.tagged {
	border-color: #bbeebb;
	background-color: #f4fff4;
}

.tagged .listTitle {
	color: #595;
	font-weight: bold;
}

.tagged .button {
	color: #000;
}

.selected .tagged {
	background-color: ColorPalette::TertiaryLight;
	border: 1px solid ColorPalette::TertiaryMid;
}

/* from #st-incoming-links */
.tagging {
	border-color: #ebb;
	background-color: #fff4f4;
}

.tagging .listTitle {
	color: #b78;
	font-weight: bold;
}

.tagging .button {
	color: #999;
}

.selected .tagging {
	background-color: ColorPalette::TertiaryLight;
	border: 1px solid ColorPalette::TertiaryMid;
}

.tiddler {/* Tiddler body */
	border:1px solid #ccc;
	margin:0.5em;
	background:#fff;
	padding:0.5em;
}

.viewer blockquote {border-left: 0px solid}

.tiddlyLinkNonExisting {
	font-style: italic;
	border-bottom: 1px dashed;
}

.editor input, .editor textarea {
	background: #ffd;
	border-style: solid;
	border-color: #888 #ccc #ccc #888;
	border-width: 2px;
}

.tabContents {white-space: nowrap;}

#displayArea {margin: 1em 20em 0em 14em;}

#sidebar {
	position: absolute;
	right: 3px;
	width: 21em;
	font-size: .9em;
}

#sidebarOptions .button {
	border-color: #eee;
}

#sidebarTabs .tabContents {
	width: 20em;
	overflow: hidden;
}

.viewer tt {
	font-size: 1.2em;
	line-height: 1.4em;
}

ul {list-style-type: square;}
ul ul {list-style-type: circle;}

ol {list-style-type: decimal;}
ol ol {list-style-type: decimal;}
ol ol ol {list-style-type: decimal;}
ol ol ol ol {list-style-type: decimal;}
ol ol ol ol ol {list-style-type: decimal;}
ol ol ol ol ol ol {list-style-type: decimal;}

/*}}}*/
/***
SocialtextScreenStyle
http://www.eu.socialtext.net/static/2.0.0.1/css/st/screen.css
***/

/*{{{*/
body {
	font-family: Arial, sans-serif;
	color: #000;
	background: #eee;
	margin: 0;
}

/* Wiki Navigation */

.st-wiki-nav {
	clear: both;
	margin-left: 10px;
	margin-right: 10px;
}
.st-wiki-nav-content {
	background: url('../../images/st/wiki-nav/solid.gif') repeat-x left bottom;
	margin-left: 24px;
	margin-right: 24px;
	padding-top: 3px;
	min-height: 24px;
}
* html .st-wiki-nav-content {
	padding-bottom: 3px;
	height: 24px;
}

.st-wiki-nav-right {
	background: url('../../images/st/wiki-nav/right-round.gif') no-repeat bottom right;
}

.st-wiki-nav-left {
	background: url('../../images/st/wiki-nav/left-round.gif') no-repeat bottom left;
}

#st-home {
	float: left;
	margin-right: 60px;
	padding-top: 2px;
}

#st-home-link {
	color: white;
	text-decoration: none;
	font-weight: bold;
	font-family: Helvetica, sans-serif;
	font-size: 90%;
}

#st-editing-prefix-container {
	border-collapse: collapse;
	width: 100%;
	padding: 0px;
	margin: 0px;
	margin-bottom: -20px;
}

#st-editing-prefix-container tr td {
	margin: 0px;
	padding: 0px;
}

#st-editing-title {
	color: black;
	background-color: white;
	text-decoration: none;
	font-weight: bold;
	font-family: Helvetica, sans-serif;
	font-size: 90%;
	margin-bottom: 0.4em;
}

#st-wiki-title-invite {
	font-size: 50%;
	font-family: Helvetica, sans-serif;
}

#st-wiki-title-central-page-link {
	font-size: 50%;
	font-family: Helvetica, sans-serif;
}

#st-wiki-title-invite a {
	color: #00f;
}

#st-wiki-logo {
	text-align: center;
	clear: both;
}

#st-wiki-logo-image {
}

.st-wiki-nav-actions {
	float: right;
	color: black;
	font-size: 75%;
	padding-top: 3px;
}

.st-wiki-nav-actions a {
	padding: 2px;
	color: white;
	text-decoration: none;
	font-family: Helvetica, sans-serif;
}

/* Wiki Subnav */

#st-wiki-subnav {
	margin-top: 2px;
	font-size: 70%;
	font-weight: bold;
	font-family: Helvetica, sans-serif;
	color: #888;
}

#st-wiki-subnav a {
	padding: 2px;
	color: #008;
	text-decoration: none;
}

#st-wiki-subnav-right {
	float: right;
	margin-right: 6em;
}

#st-wiki-subnav-left {
	float: left;
	margin-left: 6em;
}
* html #st-wiki-subnav-left {
	margin-left: 3em;
}

/* Wiki Navigation Search Bar */

#st-search-form {
	margin: 0;
	padding: 0;
	padding-top: 1px;
}

#st-search-form .button-table {
	float: left;
	font-size: 79%;
	font-weight: bold;
	margin-left: 5px;
	margin-top: 1px;
}

#st-search-form #st-search-term {
	float: left;
	font-size: 60%;
}

/* Content Outline */

#st-content-border, #st-edit-border {
	position: relative;
	clear: both;
	margin-left: 3px;
	margin-right: 2px;
	margin-bottom: 0px;
	margin-top: 0px;
	border-bottom: 1px solid #eee;
}

#st-content-border-left, #st-edit-border-left {
	background: url('../../images/st/page-shadow/left.gif') left top repeat-y;
	position: relative;
}

#st-content-border-right, #st-edit-border-right {
	background: url('../../images/st/page-shadow/right.gif') right top repeat-y;
	position: relative;
}

#st-content-border-top, #st-edit-border-top {
	position: relative;
	background: url('../../images/st/page-shadow/top.gif') left top repeat-x;
}

#st-content-border-bottom, #st-edit-border-bottom {
	background: url('../../images/st/page-shadow/bottom.gif') left bottom repeat-x;
	position: relative;
}

#st-content-border-left-top, #st-edit-border-left-top {
	background: url('../../images/st/page-shadow/left-top.gif') left top no-repeat;
	position: relative;
}
#st-content-border-right-top, #st-edit-border-right-top {
	background: url('../../images/st/page-shadow/right-top.gif') right top no-repeat;
	position: relative;
}

#st-content-border-left-bottom, #st-edit-border-left-bottom {
	background: url('../../images/st/page-shadow/left-bottom.gif') left bottom no-repeat;
	position: relative;
}

#st-content-border-right-bottom, #st-edit-border-right-bottom {
	background: url('../../images/st/page-shadow/right-bottom.gif') right bottom no-repeat;
	padding-top: 5px;
	padding-bottom: 9px;
	position: relative;
}

* html #st-content-border-right-bottom, * html #st-edit-border-right-bottom {
	padding-top: 4px;
	padding-left: 7px;
	padding-right: 8px;
	position: relative;
}

.st-content-width-controller {
	width: 100%;
	position: relative;
	border-collapse: collapse;
}
.st-content-width-controller td {
	vertical-align: top;
}
.st-content {
	position: relative;
	background-color: white;
	margin-top: 0px;
	margin-left: 7px;
	margin-right: 8px;
	margin-bottom: -1px;
	border-left: 1px dotted #80a9f3;
	border-right: 1px dotted #80a9f3;
	border: 1px solid #80a9f3;
	padding: 6px 12px 12px 12px;
}
* html .st-content {
	margin-top: 0px;
	margin-left: 0px;
	margin-right: 0px;
}

/* This textarea is only for Safari. However, if we use display:none; here Safari ignores the .value operation in JS */
#st-raw-wikitext-textarea {
	width:1px;
	height:1px;
	margin:0;
	padding:0;
}

/* Action Buttons */
.button-table, .button-table tr td {
	border-collapse: collapse;
	margin: 0;
	padding: 0;
}
.button-rounded {
	background: url('../../images/st/grey-button/left-top-rounded.png') top left no-repeat;
	margin: 0;
}
.button-rounded-right-top {
	background: url('../../images/st/grey-button/right-top-rounded.png') top right no-repeat;
	margin: 0;
}
.button-rounded-left-bottom {
	background: url('../../images/st/grey-button/left-bottom-rounded.png') bottom left no-repeat;
	margin: 0;
}
.button-rounded-right-bottom {
	background: url('../../images/st/grey-button/right-bottom-rounded.png') bottom right no-repeat;
	margin: 0;
}
.button-straight {
	background: url('../../images/st/grey-button/left-top-straight.png') top left no-repeat;
	margin: 0;
}
.button-straight-right-top {
	background: url('../../images/st/grey-button/right-top-straight.png') top right no-repeat;
	margin: 0;
}
.button-straight-left-bottom {
	background: url('../../images/st/grey-button/left-bottom-straight.png') bottom left no-repeat;
	margin: 0;
}
.button-straight-right-bottom {
	background: url('../../images/st/grey-button/right-bottom-straight.png') bottom right no-repeat;
	margin: 0;
}
.button-content {
	font-size: 90%;
}
.button-content a {
	display: block;
	padding: 2px;
	padding-left: 10px;
	padding-right: 10px;
	font-family: Helvetica, Verdana, sans-serif;
	font-weight: bold;
	text-decoration: none;
	color: black;
}

.button-content input.submit {
	border: 0px;
	padding: 2px;
	padding-left: 10px;
	padding-right: 10px;
	font-family: Helvetica, Verdana, sans-serif;
	font-weight: bold;
	text-decoration: none;
	color: black;
	background-color: transparent;
}

/* Personal Homepage */

#st-homepage {
	background: white url('../../images/st/homepage/blue-fade.gif') top left no-repeat;
}

#st-homepage-layout {
	margin-top: 15px;
	clear: both;
	width: 100%;
	border-collapse: collapse;
}

#st-homepage-layout tr td.st-homepage-layout-cell {
	padding: 5px;
	vertical-align: top;
}

#st-homepage-layout-dashboard {
	width: 50%
}

#st-homepage-layout-notes {
	width: 50%;
}

#st-homepage-notes, #st-homepage-dashboard {
	text-align: left;
	width: 95%;
}

#st-user-greeting, #st-wiki-title {
	font-family: Helvetica, Verdana, sans-serif;
	font-size: 150%;
}
#st-wiki-title {
	margin-left: 5px;
}

#st-user-greeting {
	position: relative;
	text-align: right;
	float: right;
}

#st-group-notes-content, #st-personal-notes-content {
}

.st-homepage-section {
	margin-bottom: 15px;
}

#st-homepage-notes .st-homepage-section {
	background-color: white;
	border: 1px solid #aaa;
	padding: 15px;
}

.st-homepage-section-title {
	font-size: 110%;
	font-family: Helvetica, Verdana, sans-serif;
}

#st-homepage-notes .st-homepage-section-title {
	color: #aaa;
	text-decoration: underline;
}

.st-homepage-notes-edit-link {
	background: url('../../images/st/homepage/edit-icon.gif') no-repeat left top;
	display: block;
	text-indent: -2000px;
	height: 13px;
	width: 36px;
	text-decoration: none;
	padding:0;
}
* html .st-homepage-notes-edit-link {
	border:1px solid white;
}

.st-homepage-notes-edit {
	font-family: Verdana, sans-serif;
	font-size: 65%;
	float: right;
}

.st-homepage-notes-content {
	font-size: 85%;
	margin-top: 10px;
	padding-top: 0px;
	padding-bottom: 0px;
	font-family: Verdana, Helvetica, sans-serif;
}

#st-dyk {
	border-color: #cca !important;
	background-color: #ffe !important;
}

#st-dyk-title {
	color: #e4a020 !important;
	text-decoration: none !important;
}


/* Homepage Simple List */

#st-whats-new-title-link {
	background: url('../../images/st/homepage/icon-28-pages.gif') no-repeat left top;
}
#st-watchlist-title-link {
	background: url('../../images/st/homepage/icon-28-star.gif') no-repeat left top;
}
#st-wikis-title-link {
	background: url('../../images/st/homepage/icon-28-group.gif') no-repeat left top;
}
.st-homepage-simplelist-title-link {
	display: block;
	padding-left: 32px;
	min-height: 32px;
}
* html .st-homepage-simplelist-title-link {
	height: 32px;
}

.st-homepage-simplelist-title {
}

.st-homepage-simplelist-table {
	margin-left: 25px;
	border: 1px dashed #ddd;
	border-collapse: collapse;
	font-family: Verdana, Helvetica, sans-serif;
	font-size: 80%;
	width: 95%;
}

.st-homepage-simplelist-table td {
	padding: 2px;
}

.st-homepage-simplelist-table tr.st-homepage-simplelist-row-odd {
	background-color: #f3f7f7;
}

.st-homepage-simplelist-table tr.st-homepage-simplelist-row-even {
	background-color: white;
}

.st-homepage-simplelist-table a {
	color: #4f55dd;
	text-decoration: none;
}

.st-homepage-simplelist-table a:visited {
	color: #551a8b;
}

.st-homepage-simplelist-subleft {
	font-size: 80%;
	margin-left: 1em;
	color: #666;
}

.st-homepage-simplelist-right {
	width: 20%;
}

.st-homepage-simplelist-subright {
	font-size: 80%;
	color: #666;
}

.st-homepage-simplelist {
}

.st-homepage-simplelist-header {
	min-height: 35px;
}

.st-homepage-simplelist-header .button-table {
	float: right;
	margin-right: 15px;
	font-size: 95%;
}

.st-homepage-simplelist-header .button-table .button-content {
	padding: 1px;
}

.st-homepage-whatsnew-author, .st-homepage-whatsnew-date {
	color: #555;
}
.st-homepage-whatsnew-attribution {
	padding-left: 1em;
	font-size: 80%;
	color: #aaa;
}

/* Homepage Wikis List */

#st-wikis-title {
}

/* Data and Templates */

.st-jst-template, .st-json {
	display: none;
}

/* Page Sidebox Common Styles */

#st-page-boxes-toggle {
	position: relative;
	float: right;
	text-align: right;
	font-family: Verdana, Arial, sans-serif;
	font-weight: bold;
	font-size: 80%;
	margin-bottom: 0.7em;
}

#st-page-boxes-toggle-link {
	text-decoration: none;
}

#st-page-boxes-underlay {
	float: right;
	margin-top: -10px;
	margin-right: 10px;
	background: white;
	z-index: 198;
	clear: both;
	margin-left: 15px;
}
* html #st-page-boxes-underlay {
	margin-right: 4px;
}
#st-page-boxes {
	background: inherit;
	position: absolute;
	right: 23px;
	z-index: 199;
	margin-top: 15px;
	margin-left: 20px;
}
#st-page-boxes, #st-page-boxes-underlay {
	width: 225px;
	/* padding-left: 15px; */ /* Gives the white border effect, cwest dislikes it. */
}

.st-page-box {
	border: 1px solid black;
	padding: 5px;
	font-family: Verdana, Helvetica, sans-serif;
	font-size: 80%;
	margin-top: 15px;
}

.st-page-box-title {
	font-family: Helvetica, Verdana, sans-serif;
	font-weight: bold;
	margin-bottom: 10px;
}

.st-page-box-listing {
	margin: 0;
	padding: 0;
}

.st-page-box-listing-entry {
	display: block;
}

.st-page-boxes-nobacklinks {
	font-family: Verdana, Helvetica, sans-serif;
	font-size: 90%;
	color: #888;
}

.st-page-box-first {
	margin-top: 0px;
}

/* Page Display */

#st-page-content {
	clear: left;
	margin-top: 6px;
	margin-bottom: 0;
	padding-bottom: 0;
}

#st-page-content, #st-page-content td {
	font-family: Verdana, Helvetica, sans-serif;
	font-size: 90%;
}

#st-page-wiki-title {
	font-family: Helvetica, Verdana, sans-serif;
	font-size: 65%;
	font-weight: bold;
	color: #aaa;
	margin-bottom: 0.2em;
	margin-top: 0.1em;
	padding-top: 0;
}

#wiki {
	margin: 0;
	padding: 0;
}

#st-page-title {
}

#st-page-titletext, .st-page-title {
	font-family: Helvetica, Verdana, sans-serif;
	font-size: 150%;
	font-weight: bold;
	color: #888;
	border-bottom: 1px solid #888;
}

#st-newpage-pagename-edit {
	font-family: inherit;
	font-size: inherit;
	font-weight: inherit;
	color: #000;
	border: 1px solid black;
	padding-left: 0.3em;
	background-color: #ffd;
}

#st-page-details {
	font-style: italic;
	font-size: 75%;
	font-family: Georgia, serif;
	margin: 6px 10px 0 10px;
}

#st-page-details-feed-icon {
	vertical-align: middle;
	border: none;
}

#st-page-stats {
	float: right;
	vertical-align: middle;
}

#st-attribution {
	float: left;
	margin-bottom: 10px;
}

#st-page-editing-wysiwyg {
	background: #ffd;
	border-style: solid;
	border-color: #888 #ccc #ccc #888;
	border-width: 2px;
	width: 100%;
}

#st-page-editing-toolbar {
	margin-left: -6px;
	overflow: hidden;
	float: left;
	height: 25px;
}

#wikiwyg_wikitext_textarea {
	margin-top: 4px;
	background: #ffd;
	border-style: solid;
	border-color: #888 #ccc #ccc #888;
	border-width: 2px;
	width: 100%;
	font-family: monospace;
}

#st-page-maincontent {
}

#st-page-editing, #wikiwyg_wikitext_textarea {
}

#st-page-editing-pagebody-decoy, #st-page-editing-wysiwyg {
	display: none;
}

#st-editing-tools-edit {
	display: none;
}

#st-mode-wysiwyg-button
{
	font-size: 70%;
	margin-left: 4em;
}

#st-mode-wikitext-button
{
	font-size: 70%;
}

#st-edit-tips
{
	font-size: 70%;
}

.wikiwyg_button {
	background: #FFFFFF;
	border: 1px solid #FFFFFF;
	cursor: pointer;
	width: 20px;
	height: 20px;
	vertical-align: bottom;
}

.wikiwyg_button:hover {
	border: 1px outset;
}

.wikiwyg_button:active {
	border: 1px inset;
}

#wikiwyg_toolbar {
	display: none;
}

/* Sidebox Pagetools: Revisions, Watchlist */
#st-side-box-pagetools {
	border-collapse: collapse;
}

#st-rewind-norevisions {
	font-family: Helvetica, Arial, sans-serif;
	font-size: 11px;
	color: #777;
	text-decoration: none;
}

#st-side-box-pagetools a {
	font-family: Helvetica, Arial, sans-serif;
	font-size: 11px;
	color: #555;
	text-decoration: none;
}

/* Page View Tags/Incoming Links Sidebox */

#st-tags {
	background: #f4fff4;
	border-color: #bbeebb;
	color: #999;
}

#st-tags-title {
	color: #595;
}

#st-tags-addlink, #st-tags-addbutton {
	font-weight: bold;
}

#st-tags-listing {
	margin-bottom: 5px;
}

#st-tags-addinput, #st-tags-message, #st-tags-suggestion {
	display: none;
}

#st-tags-deletemessage {
	font-size: 90%;
	color: #555;
	display: none;
	margin-top: 0.5em;
	margin-bottom: 0.5em;
}

#st-tags-suggestion {
	margin-top: 2px;
}

.st-tags-level1 {
	font-size: 90%;
}

.st-tags-level2 {
	font-size: 100%;
}

.st-tags-level3 {
	font-size: 110%;
}

.st-tags-level4 {
	font-size: 120%;
}

.st-tags-level5 {
	font-size: 130%;
}

.st-tags-tagline .st-tags-tagdelete {
	text-decoration: none;
	color: #ccc;
}

.st-tags-tagline a {
	text-decoration: none;
	color: #444;
}

#st-tags-field {
	width: 95%;
}

#st-incoming-links {
	border-color: #ebb;
	background-color: #fff4f4;
}

#st-incoming-links-title {
	color: #b78;
}

#st-attachments {
	border-color: #bbe;
	background-color: #f4f4ff;
}

#st-attachments-uploadbutton, #st-attachments-managebutton {

}
#st-attachments-buttons-uploadbutton {
	margin: 0px;
	padding: 0px;
	padding-left: 2px;
}
#st-attachments-buttons-managebutton {
	margin: 0px;
	padding: 0px;
	padding-right: 2px;
}

#st-attachments-buttons td {
	padding-right: 3px;
	font-size: 99%;
}

#st-attachments-buttons {
	border-collapse: collapse;
	margin: 0px;
	padding: 0px;
	margin-top: 5px;
}

#st-attachments-title {
	color: #77b;
}

.st-attachments-line {
	width:100%;
	overflow:hidden;
}

/* Actions Bar */

#st-actions-bar-spacer {
	clear:both;
	height:0.5em;
	overflow:hidden;
}

#st-actions-bar-spacer-clear {
	clear:both;
	height:1px;
	overflow:hidden;
}


#st-actions-bar, #st-editing-tools-bar {
	margin-left: 30px !important;
	margin-right: 30px !important;
}

/* Footer */
#st-footer {
	margin-top: -8px;
	margin-bottom: 5px;
	clear: both;
}

/* Socialtext Attribution */

#st-socialtext-attribution {
	clear: both;
	text-align: center;
	font-size: 80%;
	font-family: Helvetica, sans-serif;
}

#st-socialtext-attribution-link {
	text-decoration: none;
}

#st-socialtext-attribution-image {
	border: 0;
}


/* Page Actions */

#st-edit-button-border-left-middle, #st-login-to-edit-button-border-left-middle {
	background: url('../../images/st/button-blue/left-middle.gif') left top repeat-y;
}
#st-edit-button-border-right-middle, #st-login-to-edit-button-border-right-middle {
	background: url('../../images/st/button-blue/right-middle.gif') right top repeat-y;
}

#st-edit-button-border-left-top, #st-login-to-edit-button-border-left-top {
	background: url('../../images/st/button-blue/left-top.gif') left top no-repeat;
}
#st-edit-button-border-right-top, #st-login-to-edit-button-border-right-top {
	background: url('../../images/st/button-blue/right-top.gif') right top no-repeat;
}

#st-edit-button-border-left-bottom, #st-login-to-edit-button-border-left-bottom {
	background: url('../../images/st/button-blue/left-bottom.gif') left bottom no-repeat;
}

#st-edit-button-border-right-bottom, #st-login-to-edit-button-border-right-bottom {
	background: url('../../images/st/button-blue/right-bottom.gif') right bottom no-repeat;
}

#st-edit-button-link, #st-login-to-edit-button-link {
}

#st-comment-button-border-left-middle {
	background: url('../../images/st/button-purple/left-middle.gif') left top repeat-y;
}

#st-comment-button-border-right-middle {
	background: url('../../images/st/button-purple/right-middle.gif') right top repeat-y;
}

#st-comment-button-border-left-top {
	background: url('../../images/st/button-purple/left-top.gif') left top no-repeat;
}

#st-comment-button-border-right-top {
	background: url('../../images/st/button-purple/right-top.gif') right top no-repeat;
}

#st-comment-button-border-left-bottom {
	background: url('../../images/st/button-purple/left-bottom.gif') left bottom no-repeat;
}

#st-comment-button-border-right-bottom {
	background: url('../../images/st/button-purple/right-bottom.gif') right bottom no-repeat;
}

#st-comment-button-link {
}

#st-save-button-border-left-middle {
	background: url('../../images/st/button-green/left-middle.gif') left top repeat-y;
}
#st-save-button-border-right-middle {
	background: url('../../images/st/button-green/right-middle.gif') right top repeat-y;
}

#st-save-button-border-left-top {
	background: url('../../images/st/button-green/left-top.gif') left top no-repeat;
}
#st-save-button-border-right-top {
	background: url('../../images/st/button-green/right-top.gif') right top no-repeat;
}

#st-save-button-border-left-bottom {
	background: url('../../images/st/button-green/left-bottom.gif') left bottom no-repeat;
}

#st-save-button-border-right-bottom {
	background: url('../../images/st/button-green/right-bottom.gif') right bottom no-repeat;
}

#st-save-button-link {
}

#st-preview-button-border-left-middle {
	background: url('../../images/st/button-gold/left-middle.gif') left top repeat-y;
}
#st-preview-button-border-right-middle {
	background: url('../../images/st/button-gold/right-middle.gif') right top repeat-y;
}

#st-preview-button-border-left-top {
	background: url('../../images/st/button-gold/left-top.gif') left top no-repeat;
}
#st-preview-button-border-right-top {
	background: url('../../images/st/button-gold/right-top.gif') right top no-repeat;
}

#st-preview-button-border-left-bottom {
	background: url('../../images/st/button-gold/left-bottom.gif') left bottom no-repeat;
}

#st-preview-button-border-right-bottom {
	background: url('../../images/st/button-gold/right-bottom.gif') right bottom no-repeat;
}

#st-preview-button-link {
}

#st-cancel-button-border-left-middle {
	background: url('../../images/st/button-crimson/left-middle.gif') left top repeat-y;
}
#st-cancel-button-border-right-middle {
	background: url('../../images/st/button-crimson/right-middle.gif') right top repeat-y;
}

#st-cancel-button-border-left-top {
	background: url('../../images/st/button-crimson/left-top.gif') left top no-repeat;
}
#st-cancel-button-border-right-top {
	background: url('../../images/st/button-crimson/right-top.gif') right top no-repeat;
}

#st-cancel-button-border-left-bottom {
	background: url('../../images/st/button-crimson/left-bottom.gif') left bottom no-repeat;
}

#st-cancel-button-border-right-bottom {
	background: url('../../images/st/button-crimson/right-bottom.gif') right bottom no-repeat;
}

#st-cancel-button-link {
}

#st-edit-more-button-border-left-middle {
	background: url('../../images/st/button-blue/left-middle.gif') left top repeat-y;
}
#st-edit-more-button-border-right-middle {
	background: url('../../images/st/button-blue/right-middle.gif') right top repeat-y;
}

#st-edit-more-button-border-left-top {
	background: url('../../images/st/button-blue/left-top.gif') left top no-repeat;
}
#st-edit-more-button-border-right-top {
	background: url('../../images/st/button-blue/right-top.gif') right top no-repeat;
}

#st-edit-more-button-border-left-bottom {
	background: url('../../images/st/button-blue/left-bottom.gif') left bottom no-repeat;
}

#st-edit-more-button-border-right-bottom {
	background: url('../../images/st/button-blue/right-bottom.gif') right bottom no-repeat;
}

#st-edit-more-button-link {
}

.st-page-action-button-link {
	min-height: 24px;
	min-width: 100px;
	text-align: center;
	font-family: Helvetica, Verdana, sans-serif;
	font-size: 90%;
	text-decoration: none;
	color: #fff;
	font-weight: bold;
	display: block;
	padding-top: 8px;
	padding-bottom: 0px;
	margin-bottom: -3px;
	width: 100%;
	margin-left: -2px;
}
* html .st-page-action-button-link {
	padding-top: 5px;
	padding-bottom: 0px;
	height: 24px;
}

.st-page-action-button {
	float: left;
	margin: 0;
	padding: 0;
	margin-right: 10px;
	min-height: 20px;
	border-collapse: collapse;
	width: 100px;
}

/* Attach File Interface */

#st-attachments-attachinterface {
	font-family: Helvetica, sans-serif;
	font-size: 90%;
	display: none;
	position: fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 2000;
	background-image: url('../../images/st/popup/bg.png');
}
#st-attachments-manageinterface {
	font-family: Helvetica, sans-serif;
	font-size: 90%;
	display: none;
	position: absolute;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 2000;
	background-image: url('../../images/st/popup/bg.png');
}

* html #st-attachments-attachinterface {
	background-image: none;
}
* html #st-attachments-manageinterface {
	background-image: none;
}
* html .popup-overlay {
	background-image: url('../../images/st/popup/bg.png');
	background-color: #000;
	opacity: .70;
	position: absolute;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 2001;
}

#st-attachments-attach-interface {
	z-index: 2002;
	background-color: #fff;
	color: #000;
	border: 4px solid #ccc;
	padding: 1em;
	width: 520px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 10%;
	position: absolute;
	top: 0px;
}

* html #st-attachments-attach-interface {
}

#st-attachments-attach-formtarget {
	width: 0px;
	height: 0px;
	border: 0;
	padding: 0;
	margin: 0;
}

#st-attachments-attach-message {
	font-size: 90%;
	font-family: Verdana, Arial, Helvetica, Sans-Serif;
}

#st-attachments-attach-title {
	font-weight: bold;
	font-size: 120%;
}

#st-attachments-attach-close {
	float: right;
	margin-top: 6px;
}

#st-attachments-attach-uploadbutton {
	float: right;
	margin-right: 6px;
	margin-top: 6px;
	padding-bottom: 0;
}

#st-attachments-attach-fileprompt {
	margin: 0.2em 0 0.4em 0;
	padding-bottom: 0px;
}

#st-attachments-attach-submit {
	font-size: 90%;
	font-weight: bold;
}

#st-attachments-attach-filename {
	font-size: 90%;
}

#st-attachments-attach-uploadmessage {
	font-weight: bold;
	margin-bottom: 1em;
	display: none;
}

#st-attachments-attach-error {
	font-weight: bold;
	color: #f00;
	margin-bottom: 1em;
	display: none;
}

#st-attachments-attach-list {
	display: none;
	color: #666;
	font-size: 90%;
	margin-top: 1em;
	margin-bottom: 1em;
	border-top: 1px solid #4949BA;
	border-bottom: 1px solid #4949BA;
	background-color: #F5F5F5;
	padding: 3px;
}

.st-attachments-attach-listlabel {
	font-size: 90%;
	color: #4949BA;
}

/* Queue File Dialog */

#st-attachmentsqueue-interface {
	font-family: Helvetica, sans-serif;
	font-size: 90%;
	display: none;
	position: fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	background-image: url('../../images/st/popup/bg.png'); /* Don't forget IE hack for ship! */
	z-index: 2000;
}

* html #st-attachmentsqueue-interface {
	background-image: none;
}

#st-attachmentsqueue-dialog {
	z-index: 2002;
	background-color: #fff;
	color: #000;
	border: 4px solid #ccc;
	padding: 1em;
	width: 530px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 10%;
	position: absolute;
	top: 0px;
}

* html #st-attachmentsqueue-dialog {
}

#st-attachmentsqueue-fileprompt {
	margin-bottom: 0.4em;
	margin-top: 0;
	padding-bottom: 0;
}

#st-attachmentsqueue-title {
	font-weight: bold;
	font-size: 120%;
}

#st-attachmentsqueue-close {
	float: right;
	margin-top: 6px;
}

#st-attachmentsqueue-uploadbutton {
	float: right;
	margin-right: 6px;
	margin-top: 6px;
	padding-bottom: 0;
}

#st-attachmentsqueue-submit {
	font-size: 90%;
}

#st-attachmentsqueue-filename {
	font-size: 90%;
}

#st-attachmentsqueue-message {
	font-size: 90%;
	font-family: Verdana, Arial, Helvetica, Sans-Serif;
}

#st-attachmentsqueue-uploadmessage {
	font-weight: bold;
	margin-bottom: 1em;
	display: none;
}

#st-attachmentsqueue-error {
	font-weight: bold;
	color: #f00;
	margin-bottom: 1em;
	display: none;
}

#st-attachmentsqueue-list {
	display: none;
	color: #666;
	font-size: 90%;
	margin-top: 1em;
	margin-bottom: 1em;
	border-top: 1px solid #4949BA;
	border-bottom: 1px solid #4949BA;
	background-color: #F5F5F5;
	padding: 3px;
}

.st-attachmentsqueue-listlabel {
	font-size: 90%;
	color: #4949BA;
}

/* Lists */

tr.st-trbg-even, tr.st-trbg-even td{
	background-color: #f3f7f7;
}

tr.w-st-even-row, tr.w-st-even-row td {
	background-color: #f3f7f7;
}

.query-results-header-title, .query-results-header-last-edit-by {
	text-align: left;
}


.query-results-row-revisions {
	text-align: right;
}

.query-results-content {
	font-size: 85%;
	border-collapse: collapse;
	border: 1px dashed #ddd;
	border-left: 1px solid #ddd;
	border-right: 1px solid #ddd;
}

.query-results-row {
	border-collapse: collapse;
	border: 1px dashed #ddd;
	border-left: 1px solid #ddd;
	border-right: 1px solid #ddd;
}

.query-results-row a {
	text-decoration: underline;
	color: #00f;
}

.query-results-row td {
	font-family: Verdana;
	padding: 0.3em;
	border-left: 1px dashed #ddd;
	border-right: 1px dashed #ddd;
	border-top: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
}

.query-results-header-row {
	border-collapse: collapse;
	border: 1px dashed #ddd;
	border-left: 1px solid #ddd;
	border-right: 1px solid #ddd;
}

.query-results-header-row a {
	text-decoration: underline;
	color: #00f;
}

.query-results-header-row th {
	font-family: Helvetica;
	padding: 0.3em;
	border-left: 1px dashed #ddd;
	border-right: 1px dashed #ddd;
	border-top: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
}

div.st-actionbutton {
	float: left;
}

div#deleteme-st-actions-bar {
	clear: both;
	margin: 0.8em 20px 0.2em auto;
	padding: 0;
}

/* Manage File Interface */



#st-attachments-manage-interface {
	z-index: 2002;
	background-color: #fff;
	color: #000;
	border: 4px solid #ccc;
	padding: 1em;
	width: 520px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 10%;
	position: absolute;
	top: 0px;
}

#st-attachments-manage-filetable {
	height: 150px;
	margin: 0;
	padding: 0;
	width: 100%;
	overflow: auto;
	border: 1px solid #ccc;
}

#st-attachments-manage-filelisting tbody td {
	font-size: 90%;
}
#st-attachments-manage-filelisting {
	width: 100%;
	border-collapse: collapse;
	border: 0;
	margin: 0;
	padding: 0;
}

#st-attachments-manage-fileheader {
	background: #ccc;
	font-weight: bold;
	border-bottom: 1px black solid;
}

#st-attachments-manage-close {
	float: right;
	margin-top: 3px;
	margin-right: -2px;
	font-weight: bold;
}

#st-attachments-manage-delete {
	margin-top: 3px;
	float: left;
	font-weight: bold;
}

.st-attachments-manage-filerow {
	border-bottom: 1px solid #ccc;
}

.row-odd {
	background-color: #eee;
}

.row-even {
	background-color: #fff;
}

.row-on {
	background-color: #009 !important;
	color: white !important;
}

.row-on a {
	color: #fff !important;
}

#st-attachments-manage-deletemessage {
	color: red;
}

/* Page tools icons */

#st-pagetools-print {
	background: url('../../images/st/pagetools/print.gif')
	left center no-repeat;
}

#st-pagetools-email {
	background: url('../../images/st/pagetools/email.gif')
	left center no-repeat;
}

#st-pagetools-tools {
	background: url('../../images/st/pagetools/tools.gif')
	left center no-repeat;
}

/*
 #st-pagetools-watch {
	background: url('../../images/st/pagetools/watch-blue.gif')
	left center no-repeat;
}
*/


/* *********** Settings *********** */

#st-settings-pane {
}
* html #settings-pane { font-size: 85%;}

.settings-start-table {
}
* html .settings-start-table { font-size: 90%;}

#st-settings-select {
	padding: 0px 10px 10px 10px;
	vertical-align: top;
	width: 1px;

	background-color: #eff1ec;
	border: none;
}

#st-settings-section {
	padding: 0px 10px 10px 10px;
	vertical-align: top;
}

.settings-top-header {
	margin-top: 1em;
	font-weight: bold;
	width: 15em;
}

.settings-header {
	margin-top: 1em;
	font-weight: bold;
}

.settings-selections {
	padding: 0px 0px 0px 20px;
	line-height: 1.5em;
}

.settings-selections a:visited, .settings-selections a:active {
	color: #0000ff;
}

.settings-link {
	clear: both;
	display: block;
}

.settings-section-left {
	text-align: right;
}

.settings-label {
	font-weight: bold;
}

.settings-help {
	color: #888;
}

.settings-comment {
}

.users-invite-message {
	padding: 0.5em 0.5em 0.5em 2em;
	background-color: #eee;
	/* This seems necessary to fix an IE bug that sometimes
		causes the text in this div to be invisible */
	z-index: 1000;
}

.workspace-entry-header {
	margin-top: .5em;
	font-weight: bold;
}

.workspace-entry {
	margin-left: 3em;
}

.workspace-entry-p {
	margin-top: .5em;
	margin-bottom: .75em;
}

.workspace-subentry {
	font-style: italic;
	font-weight: bold;
	margin-left: 1.5em;
}

.preferences-td {
	padding:.5em 0 1.5em 0;
}

.preferences-query {
	text-align: left;
}

.preference-radio {
	background-color: #cec;
}
.user-settings-listall-headings td {
	background-color: #eff3ef;
}

#st-settings-save {
	padding-bottom: 0.5em;
}

.standard-button-cancel {
	font-weight: bold;
	background-color: #71004b;

	border-left: 1px solid #aaa;
	border-top: 1px solid #aaa;
	border-bottom: 2px solid #333;
	border-right: 2px solid #333;
	color: #f4f3b9;
	width: 8em;
}

.standard-button-submit {
	font-weight: bold;
	background-color: #656084;

	border-left: 1px solid #aaa;
	border-top: 1px solid #aaa;
	border-bottom: 2px solid #333;
	border-right: 2px solid #333;
	color: #f4f3b9;
	width: 8em;
}

#st-settings {
	font-family: Verdana, Arial, Helvetica, Sans-Serif;
	font-size: 90%;
}


/* Listview Tabs */


#st-listview a:visited {
	color: #551a8b;
}
#st-listview-tabs ul {
	display: block;
	list-style: none outside;
	margin: 0 0 0 4em;
	padding: 0;
	font-family: Helvetica, Arial, Sans-serif;
	font-size: 80%;
}

#st-listview-tabs li {
	display: block;
	float: left;
	margin: 0 0.8em 0 0;
	padding: 3px 0.6em 0 0.6em;
	border: 1px solid #d8d8d8;
	border-bottom: 1px solid rgb(128, 169, 243);
	background-color: #f4f4f4;
	position: relative;
	bottom: -2px;
}

#st-listview-tabs li.spacer {
	margin: 0 0.8em 0 2em;
}

#st-listview-tabs a {
	color: #bbb;
	text-decoration: none;
}

#st-listview-tabs li.selected {
	background-color: #fff !important;
	border: 1px solid rgb(128, 169, 243) !important;
	border-bottom: 1px solid #fff !important;
	font-weight: bold !important;
}

#st-listview-tabs li.selected a {
	color: #000 !important;
}

/* Category List Display */

#st-category-display-links {
	margin-bottom: 1em;
	font-size: 90%;
}

#st-tag-listbody {
	font-family: Helvetica, Verdana, sans-serif;
}

/* Attachments List Display */

#st-attachments-list-body table.button-table {
	margin-top: 0.1em;
	font-size: 80%;
}


/* ********** PageTools Menu ************** */

div#st-editing-tools {
	float: left;
}

div#st-pagetools {
	z-index: 300;
	font-family: Helvetica, Verdana, sans-serif;
	font-size: 10px;
	float: right;
	margin: 18px 0 0 0em;
	color: #000;
	vertical-align: bottom;
	position: relative;
}

#st-pagetools a {
	text-decoration: none;
	color: black;
	padding-left: 17px;
}

#st-pagetools span {
	color: inherit;
	padding-left: 17px;
	vertical-align: top;
}

#st-pagetools span.st-watchlist-link {
	color: inherit;
	vertical-align: top;
}

.st-watchlist-link {
	cursor: pointer;
}

div#st-pagetools ul.level2 {
	z-index: 300;
	margin: 0;
	padding: 0;
	background: white;
	border: 1px solid #CCC;
	border-width: 0 1px;
}

div#st-pagetools li {
	position: relative;
	list-style: none;
	margin: 0;
	float: left;
	width: 7em;
	line-height: 11px;
}

div#st-pagetools ul ul li:hover {
	background: #BFE2FF;
}

div#st-pagetools li a {
	display: block;
	text-decoration: none;
}

div#st-pagetools>ul a {
	width: auto;
}

div#st-pagetools ul ul {
	position: absolute;
	width: auto;
	display: none;
}

div#st-pagetools ul ul li {
	line-height: 1.5em;
/*	width: 100%; */
	width: 14em;
}

.first {
	border-top: 1px solid #CCC;
}

.separator {
	border-bottom: 1px solid #CCC;
}

div#st-pagetools ul ul li a {
	border-bottom: 1px solid #CCC;
	padding-left: 15px;
	padding-right: 3px;
	margin-right: 3px;
	border: 0px;
}

div#st-pagetools li.submenu li.submenu:hover {
	z-index: 300;
	background-color: #BFE2FF;
}

div#st-pagetools ul.level1 li.submenu:hover ul.level2 {
	display:block;
}

div#st-pagetools ul.level2 {
	top: 1.0em;
	left: -9.5em;
}

/*

=head2 Revision List Display

Change these styles to update the page revision list.

*/

#st-revision-list-table {
	border-collapse: collapse;
	font-size: 85%;
	color: #000;
}

.st-page-title-decorator {
	color: #C80000;
}

.st-revision-header-emphasis {
	color: #C80000;
}

.st-revision-list-compare-button-row {
}

.st-revision-list-compare-button-cell {
	padding-top: 0.3em;
	text-align: center;
}

.st-revision-list-compare-button {
}

#st-revision-list-header-row {
}

#st-revision-list-header-select {
	padding: 6px 2px 2px 2px;
	text-align: center;
}

#st-revision-list-header-revision {
	padding: 6px 2px 2px 2px;
	text-align: left;
}

#st-revision-list-header-edited-by {
	padding: 6px 2px 2px 2px;
	text-align: center;
}

#st-revision-list-header-date {
	padding: 6px 2px 2px 2px;
	text-align: center;
}

.st-revision-list-row {
	border-collapse: collapse;
	border: 1px dashed #ddd;
	border-left: 1px solid #ddd;
	border-right: 1px solid #ddd;
}

.st-revision-list-row td {
	font-family: Verdana;
	padding: 0.3em;
	border-left: 1px dashed #ddd;
	border-right: 1px dashed #ddd;
	border-top: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
}

.st-revision-list-row-select {
	padding: 3px 0 2px 0;
	text-align: center;
}

.st-revision-list-row-select-old {
}

.st-revision-list-row-select-new {
}

.st-revision-list-row-revision {
}

.st-revision-list-row-revision-link {
}

.st-revision-list-row-edited-by {
}

.st-revision-list-row-date {
}

/* Revision Menu */

#st-pagetools.st-revision-view-bar {
	float: left;
}

ul.st-revision-menu {
	list-style: none;
	margin: 0;
	padding: 0.2em;
	font-size: 80%;
}

ul.st-revision-menu li {
	float: left;
	padding: 0 0.4em 0 0.4em;
	border-right: thin solid #000000;
}

ul.st-revision-menu li.st-last {
	border-right: none;
}

#st-restore-revision-button {
	font-size: 80%;
}

/*

=head2 Revision Compare Display

When comparing two revisions of a page, these styles apply.

*/

#st-revision-compare-table {
	background-color: #f0f0f0;
}

#st-revision-compare-table td {
	background-color: white;
}

.st-revision-compare-old {
	background-color: #fdd;
	text-decoration: line-through;
}
.st-revision-compare-new {
	background-color: #dfd;
	font-weight: bold;
}

/* Weblog View */

#st-weblog {
	padding: 0;
}

#st-content-weblog-display-width-controller {
}
#st-content-weblog-display-width-controller-nav {
	width: 230px;
	margin-left: 15px;
	border-left: 5px solid #ddd;
	margin-top: -1px;
}

#st-weblog-content {
	font-family: Verdana, Helvetica, sans-serif;
	margin-top: -1px;
	margin-bottom: -1px;
	border-top: 1px solid #80a9f3;
	border-bottom: 1px solid #80a9f3;
}

#st-weblog-title {
	font-family: 'Trebuchet MS', Verdana, Helvetica, sans-serif;
	font-family: 'Times New Roman', serif;
	background-color: #80a9f3;
	color: #fff;
	font-size: 150%;
	font-weight: bold;
	padding: 0.2em;
	padding-left: 1em;
}

#st-weblog-wikititle {
	font-family: Helvetica, Verdana, sans-serif;
	font-style: italic;
	font-size: 40%;
	color: #fff;
	margin-bottom: 0.2em;
	margin-top: 0.1em;
	padding-top: 0;
}

#st-weblog-titletext {
	font-family: Helvetica, Verdana, sans-serif;
	font-weight: bold;
	color: #fff;
}

div.st-weblog-entry {
	margin-top: 0.2em;
	margin-bottom: 4.8em;
	padding: 0 1.5em 0 1.5em;
}

.st-page-title {
	clear: both;
}

div.st-weblog-entrytitle span.text {
	font-family: Helvetica, Verdana, sans-serif;
	font-size: 150%;
	font-weight: bold;
	color: #000;
}

.st-weblog-entrycontent {
	font-family: Verdana, Helvetica, sans-serif;
	font-size: 90%;
	border-bottom: 1px solid #888;
}

.st-weblog-byline {
	float: left;
	text-align: left;
	font-style: italic;
	font-size: 70%;
	font-family: Verdana, Helvetica, sans-serif;
}

.st-weblog-post-links {
	float: right;
	text-align: right;
	font-size: 70%;
	font-family: Verdana, Helvetica, sans-serif;
}

#st-weblog-archives, #st-weblog-navigation {
	position: relative;
	float: right;
	width: 230px;
}

#st-weblog-archives {
	margin-top: 15px;
	clear: right;
}

#st-weblog-archives-title, #st-weblog-navigation-title {
	margin-left: 15px;
	font-family: Helvetica, sans-serif;
	font-size: 95%;
	font-weight: bold;
	color: #999;
	border-bottom: 2px solid #f99;
	padding-bottom: 5px;
	padding-top: 5px;
	margin-bottom: 5px;
}

#st-weblog-navigation-content {
	margin-left: 15px;
	font-size: 80%;
}

#st-weblog-archives ul {
	margin: 0;
	padding: 0;
}

#st-weblog-archives ul li {
	/* list-type: none; */
	display: block;
	font-size: 80%;
	font-family: Helvetica, sans-serif;
	padding-left: 15px;
}

#st-weblog-newpost {
	padding: 0.5em 0.7em 0.3em 0.3em;
}

#st-weblog-newpost-button {
}

#st-weblog-actionbar-chooseweblog {
	float: right;
}

#st-weblog-postbyemail {
	font-size: 70%;
	font-family: Verdana, Helvetica, sans-serif;
	color: #def;
	padding-top: 0.4em;
}

#st-weblog-postbyemail-link {
	color: #00c;
}

.st-weblog-chooseprompt {
	font-size: 90%;
	font-family: Verdana, Helvetica, sans-serif;
	padding-right: 0.2em;
	color: #000;
}

.st-spacer {
	padding-right: 0.1em;
	padding-left: 0.1em;
}

.st-weblog-preventries {
	padding-bottom: 20px;
	clear: both;
}
.st-weblog-nextentries {
	clear: both;
}

div.st-weblog-entrynav {
	margin-top: 0.2em;
	margin-bottom: 1.8em;
	padding: 0;
}

span.st-weblog-previousentries, span.st-weblog-nextentries {
	font-size: 90%;
	font-family: Verdana, Helvetica, sans-serif;
	padding-left: 1em;
}

/* ******* Page Stats ******** */

#st-usagereport-navbar {
	font-size: 80%;
	padding: 0;
	margin: 0;
}

#st-usagereport-date {
	font-weight: bold;
	margin-top: 1em;
}

#st-page-usagereport h1 {
	font-size: 1.3em;
	font-weight: bold;
	margin-top: 1.2em;
	margin-bottom: 0.3em;
}

#st-page-usagereport h2 {
	font-size: 1.1em;
	font-weight: bold;
	margin-top: 0.8em;
	margin-bottom: 0.3em;
}

/* New Page */
#st-newpage-save, #st-newpage-duplicate {
	display: none;
	position: fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	background: url('../../images/st/popup/bg.png'); /* Don't forget IE hack for ship! */
	z-index: 2000;
}

#st-newpage-save-interface {
	background-color: #fff;
	color: #000;
	border: 4px solid #ccc;
	padding: 0.5em;
	width: 450px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 10%;
	position:absolute;
	top:0px;
	z-index:2003;
}

#st-newpage-duplicate-interface {
	background-color: #fff;
	color: #000;
	border: 4px solid #ccc;
	padding: 0.5em;
	width: 530px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 10%;
	position:absolute;
	top:0px;
	z-index:2003;
}

#st-newpage-save-title, #st-newpage-duplicate-title {
	margin: 0;
	padding: 0;
	font-weight: bold;
	font-family: Helvetica, sans-serif;
	font-size: 100%;
}

#st-newpage-save-prompt, #st-newpage-duplicate-prompt {
	font-family: Helvetica, sans-serif;
	font-size: 90%;
	margin-bottom: 0.4em;
}

#st-newpage-save-buttons, #st-newpage-duplicate-buttons {
	margin-top: 0.8em;
	text-align: right;
}

.st-newpage-duplicate-option {
	font-family: Helvetica, sans-serif;
	font-size: 90%;
	margin: 0;
	padding: 0;
}

#st-newpage-duplicate-pagename {
	font-size: 90%;
}

.st-newpage-duplicate-emphasis {
	background-color: #FFFF00;
	font-weight: bold;
}

#st-newpage-save-field-pagename {
	margin-bottom: 0;
	margin-top: 0.2em;
	padding-bottom: 0;
	font-size: 90%;
}

#st-newpage-save-tip {
	margin-bottom: 0;
	margin-top: 1.2em;
	padding-bottom: 0;
	font-size: 75%;
	color: #888;
}

/* Wikitext Styling */

.wiki {
}

.wiki hr {
	margin-top: .4em;
	margin-bottom: .4em;
}

.wiki .short-rule {
	width: 25%;
}

.wiki .medium-rule {
	width: 50%
}

.wiki ul,
.wiki ol,
.wiki blockquote {
	margin-left: 2em;
	padding-left: 0em;
}

.wiki table {
	border-collapse: collapse;
}

.wiki td {
	border: 1px;
	border-style: solid;
	padding: .2em;
	vertical-align: top;
}

.wiki h1,
.wiki h2,
.wiki h3,
.wiki h4,
.wiki h5,
.wiki h6 {
	font-weight: bold;
	font-style: normal;
	margin-top: 0.1em;
	margin-bottom: 8px;
}

.wiki h1 {font-size: 200%;}
.wiki h2 {font-size: 170%;}
.wiki h3 {font-size: 145%;}
.wiki h4 {font-size: 125%;}
.wiki h5 {font-size: 110%;}
.wiki h6 {font-size: 100%;}

.wiki pre {
	background-color: #eee; /* XXX */
	margin-left: 1em;
	margin-right: 1em;
	padding: .2em;
}

.wiki .incipient {
	text-decoration: none;
	border-bottom: 1px dashed;
}

.wiki-include-title {
	background-color: #ccccff;
}

.wiki .wiki {
	position: relative;
	background-color: #ddddff;
	border: 1px solid #ccccff;
	padding: 3px;
}

.wafl_existence_error {
	color: rgb(200,0,0);
	border-bottom: 0.2em dashed rgb(200,0,0);
}

#st-edit-mode-container {
}

#st-edit-mode-view {
}

#st-page-editing-uploadbutton {
	z-index: 1500;
	float: left;
}

/* Comment UI */


body#st-commentui {
	background: #ffffff;
}

#st-commentui-container {
}

#st-commentui-container a:visited,
#st-commentui-container a:active {
	color: #00f;
}

#st-commentui-notetop {
}

#st-commentui-controls {
}

#st-commentui-savelink {
	background-color: #fffebd;
}

#st-commentui-cancellink {
}

#st-commentui-customfield {
}

#st-commentui-customfield .customfield-label {
}

#st-commentui-customfield .customfield-input {
}

#st-commentui-textarea {
	padding: 0;
	border-style: inset;
	border-width: thin;
	background-color: #ffd;
	color: black;
	width: 99%;
	height: 150px;
}

/*

=head2 Send Page by Email

Styles for the 'Send Page by Email' popup, accessed from the 'Email' dropdown
menu on the page bar.

*/

#email-page {
	background: #ffffff;
	font-size: 80%;
}

.email-page-row {
	clear: both;
}

.email-page-row-label {
	font-weight: bold;
	float: left;
	width: 5em;
	margin-left: 1.2em;
	margin-right: 1.2em;
	text-align: right;
}

.email-page-row-content {
	float: left;
	padding-bottom: 1.2em;
}

.email-page-user-select-column {
	float: left;
	padding-right: 1.2em;
	width: 14em;
}

#email-page-user-select-column-center {
	width: 10em;
}

.email-page-user-select-label {
	text-align: center;
}

#email-page-user-select-add-label {
	padding-top: 1em;
}

.email-page-user-select-button-group {
	padding-bottom: 2em;
}

.email-page-input {
	width: 120px;
	clear: both;
	display: block;
}


.email-page-select {
	width: 175px;
	font-size: x-small;
}

#email-page-error-message {
	text-align: center;
}

#email-page-buttons-container {
	clear: both;
}

#email-page-buttons {
	text-align: center;
}

.email-page-input-new {
	width: 175px;
}

/* System Status, Red with icon */

#st-system-status-alert {
	clear: both;
	width: 50%;
	margin-left: 25%;
	margin-top: 10px;
	padding: 5px;
	color: #c00;
	font-weight: bold;
	font-size: 80%;
	background: transparent url('../../images/st/system-message/important-note.gif') no-repeat 5px center;
	padding-left: 60px;
	min-height: 38px;
}
* html #st-system-status-alert {
	height: 38px;
}

/* System Status, Green */

#st-system-status {
	clear: both;
	text-align:center;
	width: 80%;
	margin-left: 10%;
	padding: 8px 0 3px 0;
	color: #0a0;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 80%;
}

.socialtextLogo {
	text-align: center;
}
/*}}}*/
/***
|''Name:''|SparklinePlugin|
|''Description:''|Sparklines macro|
***/
//{{{
if(!version.extensions.SparklinePlugin) {
version.extensions.SparklinePlugin = {installed:true};

//--
//-- Sparklines
//--

config.macros.sparkline = {};
config.macros.sparkline.handler = function(place,macroName,params)
{
	var data = [];
	var min = 0;
	var max = 0;
	var v;
	for(var t=0; t<params.length; t++) {
		v = parseInt(params[t]);
		if(v < min)
			min = v;
		if(v > max)
			max = v;
		data.push(v);
	}
	if(data.length < 1)
		return;
	var box = createTiddlyElement(place,"span",null,"sparkline",String.fromCharCode(160));
	box.title = data.join(",");
	var w = box.offsetWidth;
	var h = box.offsetHeight;
	box.style.paddingRight = (data.length * 2 - w) + "px";
	box.style.position = "relative";
	for(var d=0; d<data.length; d++) {
		var tick = document.createElement("img");
		tick.border = 0;
		tick.className = "sparktick";
		tick.style.position = "absolute";
		tick.src = "data:image/gif,GIF89a%01%00%01%00%91%FF%00%FF%FF%FF%00%00%00%C0%C0%C0%00%00%00!%F9%04%01%00%00%02%00%2C%00%00%00%00%01%00%01%00%40%02%02T%01%00%3B";
		tick.style.left = d*2 + "px";
		tick.style.width = "2px";
		v = Math.floor(((data[d] - min)/(max-min)) * h);
		tick.style.top = (h-v) + "px";
		tick.style.height = v + "px";
		box.appendChild(tick);
	}
};


}
//}}}
/***
|''Name:''|CryptoFunctionsPlugin|
|''Description:''|Support for cryptographic functions|
***/
//{{{
if(!version.extensions.CryptoFunctionsPlugin) {
version.extensions.CryptoFunctionsPlugin = {installed:true};

//--
//-- Crypto functions and associated conversion routines
//--

// Crypto "namespace"
function Crypto() {}

// Convert a string to an array of big-endian 32-bit words
Crypto.strToBe32s = function(str)
{
	var be = Array();
	var len = Math.floor(str.length/4);
	var i, j;
	for(i=0, j=0; i<len; i++, j+=4) {
		be[i] = ((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
	}
	while (j<str.length) {
		be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
		j++;
	}
	return be;
};

// Convert an array of big-endian 32-bit words to a string
Crypto.be32sToStr = function(be)
{
	var str = "";
	for(var i=0;i<be.length*32;i+=8)
		str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
	return str;
};

// Convert an array of big-endian 32-bit words to a hex string
Crypto.be32sToHex = function(be)
{
	var hex = "0123456789ABCDEF";
	var str = "";
	for(var i=0;i<be.length*4;i++)
		str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
	return str;
};

// Return, in hex, the SHA-1 hash of a string
Crypto.hexSha1Str = function(str)
{
	return Crypto.be32sToHex(Crypto.sha1Str(str));
};

// Return the SHA-1 hash of a string
Crypto.sha1Str = function(str)
{
	return Crypto.sha1(Crypto.strToBe32s(str),str.length);
};

// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
Crypto.sha1 = function(x,blen)
{
	// Add 32-bit integers, wrapping at 32 bits
	add32 = function(a,b)
	{
		var lsw = (a&0xFFFF)+(b&0xFFFF);
		var msw = (a>>16)+(b>>16)+(lsw>>16);
		return (msw<<16)|(lsw&0xFFFF);
	};
	// Add five 32-bit integers, wrapping at 32 bits
	add32x5 = function(a,b,c,d,e)
	{
		var lsw = (a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
		var msw = (a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
		return (msw<<16)|(lsw&0xFFFF);
	};
	// Bitwise rotate left a 32-bit integer by 1 bit
	rol32 = function(n)
	{
		return (n>>>31)|(n<<1);
	};

	var len = blen*8;
	// Append padding so length in bits is 448 mod 512
	x[len>>5] |= 0x80 << (24-len%32);
	// Append length
	x[((len+64>>9)<<4)+15] = len;
	var w = Array(80);

	var k1 = 0x5A827999;
	var k2 = 0x6ED9EBA1;
	var k3 = 0x8F1BBCDC;
	var k4 = 0xCA62C1D6;

	var h0 = 0x67452301;
	var h1 = 0xEFCDAB89;
	var h2 = 0x98BADCFE;
	var h3 = 0x10325476;
	var h4 = 0xC3D2E1F0;

	for(var i=0;i<x.length;i+=16) {
		var j,t;
		var a = h0;
		var b = h1;
		var c = h2;
		var d = h3;
		var e = h4;
		for(j = 0;j<16;j++) {
			w[j] = x[i+j];
			t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
		}
		for(j=16;j<20;j++) {
			w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
			t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
		}
		for(j=20;j<40;j++) {
			w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
			t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k2);
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
		}
		for(j=40;j<60;j++) {
			w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
			t = add32x5(e,(a>>>27)|(a<<5),(b&c)|(d&(b|c)),w[j],k3);
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
		}
		for(j=60;j<80;j++) {
			w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
			t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k4);
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
		}

		h0 = add32(h0,a);
		h1 = add32(h1,b);
		h2 = add32(h2,c);
		h3 = add32(h3,d);
		h4 = add32(h4,e);
	}
	return Array(h0,h1,h2,h3,h4);
};


}
//}}}
/***
|''Name:''|DeprecatedFunctionsPlugin|
|''Description:''|Support for deprecated functions removed from core|
***/
//{{{
if(!version.extensions.DeprecatedFunctionsPlugin) {
version.extensions.DeprecatedFunctionsPlugin = {installed:true};

//--
//-- Deprecated code
//--

// @Deprecated: Use createElementAndWikify and this.termRegExp instead
config.formatterHelpers.charFormatHelper = function(w)
{
	w.subWikify(createTiddlyElement(w.output,this.element),this.terminator);
};

// @Deprecated: Use enclosedTextHelper and this.lookaheadRegExp instead
config.formatterHelpers.monospacedByLineHelper = function(w)
{
	var lookaheadRegExp = new RegExp(this.lookahead,"mg");
	lookaheadRegExp.lastIndex = w.matchStart;
	var lookaheadMatch = lookaheadRegExp.exec(w.source);
	if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
		var text = lookaheadMatch[1];
		if(config.browser.isIE)
			text = text.replace(/\n/g,"\r");
		createTiddlyElement(w.output,"pre",null,null,text);
		w.nextMatch = lookaheadRegExp.lastIndex;
	}
};

// @Deprecated: Use <br> or <br /> instead of <<br>>
config.macros.br = {};
config.macros.br.handler = function(place)
{
	createTiddlyElement(place,"br");
};

// Find an entry in an array. Returns the array index or null
// @Deprecated: Use indexOf instead
Array.prototype.find = function(item)
{
	var i = this.indexOf(item);
	return i == -1 ? null : i;
};

// Load a tiddler from an HTML DIV. The caller should make sure to later call Tiddler.changed()
// @Deprecated: Use store.getLoader().internalizeTiddler instead
Tiddler.prototype.loadFromDiv = function(divRef,title)
{
	return store.getLoader().internalizeTiddler(store,this,title,divRef);
};

// Format the text for storage in an HTML DIV
// @Deprecated Use store.getSaver().externalizeTiddler instead.
Tiddler.prototype.saveToDiv = function()
{
	return store.getSaver().externalizeTiddler(store,this);
};

// @Deprecated: Use store.allTiddlersAsHtml() instead
function allTiddlersAsHtml()
{
	return store.allTiddlersAsHtml();
}

// @Deprecated: Use refreshPageTemplate instead
function applyPageTemplate(title)
{
	refreshPageTemplate(title);
}

// @Deprecated: Use story.displayTiddlers instead
function displayTiddlers(srcElement,titles,template,unused1,unused2,animate,unused3)
{
	story.displayTiddlers(srcElement,titles,template,animate);
}

// @Deprecated: Use story.displayTiddler instead
function displayTiddler(srcElement,title,template,unused1,unused2,animate,unused3)
{
	story.displayTiddler(srcElement,title,template,animate);
}

// @Deprecated: Use functions on right hand side directly instead
var createTiddlerPopup = Popup.create;
var scrollToTiddlerPopup = Popup.show;
var hideTiddlerPopup = Popup.remove;

// @Deprecated: Use right hand side directly instead
var regexpBackSlashEn = new RegExp("\\\\n","mg");
var regexpBackSlash = new RegExp("\\\\","mg");
var regexpBackSlashEss = new RegExp("\\\\s","mg");
var regexpNewLine = new RegExp("\n","mg");
var regexpCarriageReturn = new RegExp("\r","mg");

}
//}}}
{file: BusBlaster-v2.0a1.sch.landscape.pdf}

http://dangerousprototypes.com/docs/Bus_Blaster_v2_design_overview

[Xilinx CoolRunner-II]

I have two boards: v2.0a1 and v2.5

{toc}

^ UrJTAG

.pre
root@blue:/bluez/FPGA/Altera-x300# jtag 

UrJTAG 0.10 #2007
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> cable jtagkey vid=0x0403 pid=0x6010 interface=1
Connected to libftdi driver.
jtag> detect
IR length: 8
Chain length: 1
Device Id: 00000110111000011100000010010011 (0x06E1C093)
  Manufacturer: Xilinx (0x093)
  Part(0):      xc2c32a-vq44 (0x6E1C)
  Stepping:     0
  Filename:     /usr/share/urjtag/xilinx/xc2c32a-vq44/xc2c32a-vq44
Segmentation fault
# WTF?
.pre

So, compile urjtag with "libft2xx"<http://www.ftdichip.com/Drivers/D2XX.htm>

You must remove kernel modules:

.pre
jtag> cable ft2232 interface=1
error: Couldn't connect to suitable USB device.
error: ftdi/ftd2xx error: ftdi_usb_open_desc() failed: device not found
jtag> quit

root@blue:~# rmmod ftdi_sio

root@blue:~# jtag
jtag> cable ft2232 interface=1
Connected to libftd2xx driver.
jtag> detect
IR length: 8
Chain length: 1
Device Id: 00000110111000011100000010010011 (0x06E1C093)
  Manufacturer: Xilinx (0x093)
  Part(0):      xc2c32a-vq44 (0x6E1C)
  Stepping:     0
  Filename:     /usr/local/share/urjtag/xilinx/xc2c32a-vq44/xc2c32a-vq44
.pre

^ Update CPLD logic

http://dangerousprototypes.com/docs/Bus_Blaster_buffer_logic

.pre
root@blue:~# jtag

UrJTAG 0.10 #2051
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> cable ft2232 interface=1
Connected to libftd2xx driver.
jtag> detect
IR length: 8
Chain length: 1
Device Id: 00000110111000011100000010010011 (0x06E1C093)
  Manufacturer: Xilinx (0x093)
  Part(0):      xc2c32a-vq44 (0x6E1C)
  Stepping:     0
  Filename:     /usr/local/share/urjtag/xilinx/xc2c32a-vq44/xc2c32a-vq44
jtag> svf /blue-zfs/dangerous-prototypes-open-hardware/Bus_Blaster/buffer_logic/BBv2-JTAGkey-v1.4-VHDL.svf stop progress
detail: Parsing    660/664 ( 99%)detail: 
detail: Scanned device output matched expected TDO values.
.pre
Product Numbers: 1838, 1839

[Tegra] 2 tablet, possible kernel name (from schematics, not used as-is): PHJ00

Board markings: LA-746

PHJ00LA-7561P
Rev:1.0
2011-06-03

schematics: {file: compal_la-7461p_r0.3_schematics.pdf}

{toc: }

^ links

* https://forum.xda-developers.com/wiki/Lenovo_ThinkPad_Tablet
* https://www.gsmarena.com/lenovo_thinkpad-4444.php

Review:

* https://www.notebookcheck.net/Review-Lenovo-ThinkPad-Tablet-18382DG-Tablet-MID.64965.0.html

^ dock connector

https://web.archive.org/web/20150108184014/http://rootzwiki.com:80/topic/8523-reverse-engineering-the-dock-charger/

Posted 31 October 2011 - 03:09 AM #1
I got my desktop charger today and unpacked it only to rip it aparts to check whats inside.
By first view theese are the highlights:

The dock connector is 40 pins
Dock connector is on a separate small pcb with a 40 pin board to board connector to a larger board.
On this small pcb is a 12 pin MLF package marked:
AAU
NAD

Probably has a ground pad underneath.

The main pcb has a few more circuits and connectors on it.
There is a micro usb, a full size master usb, audio out and microphone jacks. A bit more exiting there is room for a HDMI connector as well there with unpopulated spaces for line filters and a hdmi circuit. By first look it seems to be a displayport or MHL to HDMI bridge chip of some kind. I is TQFP-48 package.
edit:
It seems to be a PI3VDP411LS from pericom
http://www.pericom.c...PI3VDP411LS.pdf

It is a displayport levelshifter / bridge to HDMI. It is the only 48 pin package I have found to match the input with the differential pairs.

The power supply is 20 VDC 65 Watts. It does not seem like the center connector is connected. The connector is the standard "IBM" charger, outer case ground, inner case + 20 vdc, center pin power diag.

There is a fet transistor between the dock connector and the psu marked FA1K18 and it is controlled by some regulator marked 920A4 in a SOT-223 package. The 20 VDC goes in on pin 2 and the tab on it.

the HDMI chip has differential pair inputs on pin 47,48 - 44,45 - 41,41 - 38,39

I will do my best reversing the whole schematic for this unit and split it into parts so we can make other chargers and hopefully add HDMI to the dock.

Pinout Docking Connector Thinkpad Tablet

| 1 | charge | 2 | gnd |
| 3 | charge | 4 | hdmi pin 44 In D3- |
| 5 | Charger control (to pq2) | 6 | hdmi pin 45 In D3+ |
| 7 | hdmi VDD 3.3V | 8 | gnd |
| 9 | gnd | 10 | hdmi pin 47 In D4- |
| 11 | USB Micro D- | 12 | hdmi pin 48 In D4 + |
| 13 | USB micro D+ | 14 | gnd |
| 15 | USB Master D- | 16 | nc |
| 17 | USB MAster D+ | 18 | nc |
| 19 | gnd | 20 | hdmi pin 29 SDA |
| 21 | gnd | 22 | hdmi pin 28 SCL |
| 23 | hdmi pin 41 IN D2- | 24 | hdmi pin 7 HPD_Source |
| 25 | hdmi pin 42 In D2+ | 26 | gnd |
| 27 | gnd | 28 | audio out L |
| 29 | hdmi pin 38 IN D1- | 30 | audio out R |
| 31 | hdmi pin 39 IN D1+ | 32 | headset inserted switch |
| 33 | gnd | 34 | mic inserted switch feed |
| 35 | USB micro + | 36 | mic inserted switch |
| 37 | gnd | 38 | mic tip |
| 39 | + 5V to usb master | 40 | mic ring |

Pinout AAU chipAAU chip is audio amp.
audio out
pin 10 ring
pin 11 tip
pin 2, 7 gnd

Charger stuff :
The supplied DC apater is 20Volt 3.25Amps
In the dock there is a voltage regulator PV1. It is a 3.3 V LDO Tab has 20 volts in and pin 3 gives 3.30 Volts out.
There is also a FET in SSO8 (?) package. It is controlled by 2 transistors and works only as a switch.
On the base of PQ2 (pin 1, I guess it is the base) there is a float of 3.30 volts when there is nothing in the dock. The FET is OPEN and no voltage to the charger pins.
When grounding PQ2 pin1 (dock pin 5) the FET CLOSES and the charger outputs 20,5volts which basically is the same as dc power into the dock.

Now I am just waiting for the TPT to get fully charged so I can measure if there is any difference when fully charged.

Note:
By charging at 20 volts instead of 5 volts I understand why the charger only uses 2 pins into the TPT.
At 20 volts you can transfer 4 times the energy instead of just charging at 5 volts from USB powers. There is no need for step ups to charge the LI-Po battery as it would need more than 5 volts.

This is the schematics of the charger part:

www.r-888.com/tpt/schema.pdf

I am not sure of the 2 transitors if they are pnp or npn yet but the rest is how it is.
The original mosfet is a P-channel AON7403.
The regulator is just any 3,3 volt LDO.

The TPT charger control pin 5 gets a 3,3 volt float via the resistor to the left in the schematic. When it is connected the TPT grounds the pin and the FET lets current through.

Edited by ZebCrs, 05 November 2011 - 12:56 PM.

^ adb

.pre
[Tue Oct  9 14:12:34 2018] usb 2-4: new high-speed USB device number 9 using xhci_hcd
[Tue Oct  9 14:12:34 2018] usb 2-4: New USB device found, idVendor=17ef, idProduct=7494, bcdDevice=99.99
[Tue Oct  9 14:12:34 2018] usb 2-4: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[Tue Oct  9 14:12:34 2018] usb 2-4: Product: ThinkPadTablet
[Tue Oct  9 14:12:34 2018] usb 2-4: Manufacturer: LENOVO
[Tue Oct  9 14:12:34 2018] usb 2-4: SerialNumber: MP1YCPF

dpavlin@klin:~$ adb devices
List of devices attached
MP1YCPF device

dpavlin@klin:~$ adb shell
shell@android:/ $ df
Filesystem             Size   Used   Free   Blksize
/dev                   357M    32K   357M   4096
/mnt/asec              357M     0K   357M   4096
/mnt/obb               357M     0K   357M   4096
/sqlite_stmt_journals     4M     0K     4M   4096
/system                755M   310M   445M   4096
/data                   56G     1G    54G   4096
/cache                 885M    81M   804M   4096
/mnt/pia               492M   233M   258M   4096
/mnt/persdata           19M     8M    11M   4096
/storage/sdcard0        56G     1G    54G   4096


shell@android:/ # uname -a
Linux localhost 2.6.39.4-g40c7636-dirty #1 SMP PREEMPT Thu Feb 7 20:07:37 CET 2013 armv7l GNU/Linux


1|shell@android:/ # cat /proc/cpuinfo                                          
Processor       : ARMv7 Processor rev 0 (v7l)
processor       : 0
BogoMIPS        : 996.14

processor       : 1
BogoMIPS        : 996.14

Features        : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x1
CPU part        : 0xc09
CPU revision    : 0

Hardware        : ventana
Revision        : 0000
Serial          : 0000000000000000


shell@android:/ # free
             total         used         free       shared      buffers
Mem:        731896       720924        10972            0        18392
-/+ buffers:             702532        29364
Swap:            0            0            0


shell@android:/ # cat /proc/partitions                                         
major minor  #blocks  name

 179        0   62520320 mmcblk0
 179        1       6144 mmcblk0p1
 179        2       8192 mmcblk0p2
 179        3     786432 mmcblk0p3
 179        4     921600 mmcblk0p4
 179        5       2048 mmcblk0p5
 179        6     524288 mmcblk0p6
 179        7      20480 mmcblk0p7
 259        0     143360 mmcblk0p8
 259        1      20480 mmcblk0p9
 259        2   60071936 mmcblk0p10


.pre

^ APX mode

* turn off tablet
* press rotation button and hold it
* press power button for 2 seconds

.pre
 [Tue Oct  9 14:30:41 2018] usb 2-4: new high-speed USB device number 16 using xhci_hcd
[Tue Oct  9 14:30:42 2018] usb 2-4: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.04
[Tue Oct  9 14:30:42 2018] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Tue Oct  9 14:30:42 2018] usb 2-4: Product: APX
[Tue Oct  9 14:30:42 2018] usb 2-4: Manufacturer: NVIDIA Corp.


.pre

^ nvflash

https://forum.xda-developers.com/showthread.php?t=1745450

.pre
dpavlin@klin:/virtual/android/tegra/linux4tegra/nvflash$ LD_LIBRARY_PATH=. ./nvflash --bl ../prebuilt/fastboot.stock.bin --getpartitiontable /klin/Tegra/tpt1.nvflash.getpartitiontable
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 4
   chip sku: 0x8
   chip uid: 0x0a8051c743dfd457
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: ../prebuilt/fastboot.stock.bin
| 936016/936016 bytes sent
../prebuilt/fastboot.stock.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
failed executing command 19 NvError 0x120000
command failure: get partition table failed 
.pre

^^ partition table

.pre
dpavlin@nuc:/nuc/Tegra/nvflash$ LD_LIBRARY_PATH=. ./nvflash --bl ../04.EBT.img --getpartitiontable partitiontable.txt --go
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 4
   chip sku: 0x8
   chip uid: 0x043c71c3433f8497
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 2

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: ../04.EBT.img
/ 6291456/6291456 bytes sent
../04.EBT.img sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
Succesfully updated partition table information to partitiontable.txt


.pre

^^ backup

.pre
dpavlin@nuc:/nuc/Tegra/nvflash$ grep PartitionId partitiontable.txt  | cut -d= -f2 | tr -d '\r' | xargs -i ./nvflash -r --read {} {}

# even better version which removes biggest partition (15)

dpavlin@klin:/klin/Tegra/nvflash$ grep PartitionId partitiontable.txt  | cut -d= -f2 | tr -d '\r' | grep -v 15 | xargs -i ../nvflash/nvflash -r --read {} {}


.pre

^ BCT - Boot Configuration Table

https://http.download.nvidia.com/tegra-public-appnotes/bct-overview.html

compiler: https://github.com/NVIDIA/cbootimage

.pre
dpavlin@klin:/klin/Tegra/tegrarcm$ ./src/tegrarcm readbct --bct tpt.bct

[Wed Oct 10 14:31:05 2018] usb 3-1.1: new high-speed USB device number 23 using ehci-pci
[Wed Oct 10 14:31:05 2018] usb 3-1.1: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.04
[Wed Oct 10 14:31:05 2018] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Oct 10 14:31:05 2018] usb 3-1.1: Product: APX
[Wed Oct 10 14:31:05 2018] usb 3-1.1: Manufacturer: NVIDIA Corp.

bct file: tpt.bct
device id: 0x7820
uid:  0x0a805185415fc1d7
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
reading BCT from system, writing to tpt.bct...done!


.pre

^ serial

From android:

.pre
shell@android:/ # cat /proc/cmdline                                            
tegraid=20.1.4.0.0 mem=1022M@0M android.commchip=2685344 vmalloc=256M androidboot.serialno=0a805185415fc1d7 video=tegrafb no_console_suspend=1 console=none debug_uartport=lsport,-3 usbcore.old_scheme_first=1 lp0_vec=8192@0x1d826000 tegra_fbmem=8197120@0x1d82a000 tegraboot=sdmmc charging=0 isBatteryFail=0 gpt gpt_sector=125040639 


shell@android:/ # lsof | grep tty                                              
rild        103      radio   13       ???                ???       ???        ??? /dev/ttyACM1
brcm_patc   330  bluetooth    3       ???                ???       ???        ??? /dev/ttyHS2
sh         1789      shell   24       ???                ???       ???        ??? /dev/tty
sh         1795       root   24       ???                ???       ???        ??? /dev/tty

shell@android:/ # dmesg | grep tty                                             
<6>[    6.290150] serial8250.0: ttyS0 at MMIO 0x70006300 (irq = 122) is a Tegra
<6>[    6.290475] tegra_uart.1: ttyHS1 at I/O 0x0 (irq = 69) is a unknown
<6>[    6.290727] Registered UART port ttyHS1
<6>[    6.290873] tegra_uart.2: ttyHS2 at I/O 0x0 (irq = 78) is a unknown
<6>[    6.291115] Registered UART port ttyHS2
<6>[    7.056012] cdc_acm 1-1:1.1: ttyACM0: USB ACM device
<6>[    7.067323] cdc_acm 1-1:1.3: ttyACM1: USB ACM device
<6>[    7.137758] cdc_acm 1-1:1.9: ttyACM2: USB ACM device
<4>[   15.154176] ttyACM1: Entering acm_tty_open.


.pre

^ serial port

Schematic has 4 pin debug connector with serial on it.

There are three 4-pin connectors on this side of board, and from pictures other side doesn't seem to have connectors.

Skip JLTE1 and JLTE2 connector (under ribbon to front-facing camera), they are wrong connectors, and pop rf shield off Tegra
compartment and locate JP4:

{image: IMG_20181024_165607-800px.jpg}

solder pin 1 and 2 and ground

{image: IMG_20181024_172303-800px.jpg}

JP4 pinout from schematics:

* 1 - UART4_RXD
* 2 - UART4_TXD
* 3
* 4 - GND

Pins 1 and 2 are 1.8V when device is turned on. so far, so good.

^ u-boot

.pre
dpavlin@klin:/klin/Tegra/u-boot-tegra$ export CROSS_COMPILE="arm-none-eabi-" ARCH=arm
dpavlin@klin:/klin/Tegra/u-boot-tegra$ make ventana_defconfig
.pre

press left-most button and power (top-right of tablet)

.pre
[Sun Oct 21 16:29:05 2018] usb 1-3.4.1: pl2303 converter now attached to ttyUSB3
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: new high-speed USB device number 105 using xhci_hcd
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.04
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: Product: APX
[Sun Oct 21 16:29:22 2018] usb 1-3.4.4: Manufacturer: NVIDIA Corp.

# backup bct

dpavlin@nuc:/nuc/Tegra/tpt-brokenscreen$ ../tegrarcm/src/tegrarcm --bct broken.bct readbct
bct file: broken.bct
device id: 0x7820
uid:  0x0a805185415fc1d7
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
reading BCT from system, writing to broken.bct...done!

# try u-boot

dpavlin@nuc:/nuc/Tegra/tpt-brokenscreen$ ../tegrarcm/src/tegrarcm --bct broken.bct --bootloader /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin --loadaddr 0x108000

bct file: broken.bct
bootloader file: /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin
load addr 0x108000
entry addr 0x108000
device id: 0x7820
uid:  0x0a805185415fc1d7
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
Chip UID:                0x00000000000000000a805185415fc1d7
Chip ID:                 0x20
Chip ID Major Version:   0x1
Chip ID Minor Version:   0x4
Chip SKU:                0x8 (t20)
Boot ROM Version:        0x1
Boot Device:             0x2 (EMMC)
Operating Mode:          0x3 (developer mode)
Device Config Strap:     0x0
Device Config Fuse:      0x0
SDRAM Config Strap:      0x1
sending file: broken.bct
- 4080/4080 bytes sent
broken.bct sent successfully
sending file: /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin
/ 496836/496836 bytes sent
/mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin sent successfully
dpavlin@nuc:/nuc/Tegra/tpt-brokenscreen$ 
[Sun Oct 21 16:39:58 2018] usb 1-3.4.4: USB disconnect, device number 108
.pre

Complete nfsroot with u-boot is documented in [u-boot] page.

^^ screen

LG LP101WX1 - datasheet - https://datasheetspdf.com/pdf-file/788219/LG/LP101WX1-SLN2/1

and screen seems to work with changes ported from 2.6!

.pre
                                display-timings {
                                        timing@0 {
                                                /* XXX tegra_dc_mode ventana_panel_modes */
                                                clock-frequency = <72072000>;
                                                hactive = <1280>;
                                                vactive = <800>;
                                                hback-porch = <72>;
                                                hfront-porch = <48>;
                                                hsync-len = <32>;
                                                vback-porch = <22>;
                                                vfront-porch = <3>;
                                                vsync-len = <7>;
                                                hsync-active = <1>;
                                        };
                                };


.pre

^ wifi

.pre
dpavlin@tegra20:~$ dmesg | grep brcm
[   13.971076] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4329-sdio for chip BCM4329/3

apt-get install firmware-brcm80211

# it seems to need some non-free parts

root@tegra20:/home/dpavlin# cd /lib/firmware/brcm/
wget https://raw.githubusercontent.com/armbian/firmware/master/brcm/brcmfmac4329-sdio.txt

.pre

And to make it work on 5.0 kernel you also need specific symlink for device:

.pre
root@tegra20:/lib/firmware# dmesg | grep firmware
[    5.748888] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[   14.614802] brcmfmac mmc0:0001:1: Direct firmware load for brcm/brcmfmac4329-sdio.nvidia,ventana.txt failed with error -2
[  447.338018] brcmfmac mmc0:0001:1: Direct firmware load for brcm/brcmfmac4329-sdio.nvidia,ventana.txt failed with error -2

root@tegra20:/lib/firmware/brcm# ln -sf brcmfmac4329-sdio.txt brcmfmac4329-sdio.nvidia,ventana.txt 
.pre

^ battery

without any config with ventana dts battery isn't charging which is annoying for development because you need to charge tablet often.

* The Power-Supply Subsystem - Sebastian Reichel, Collabora https://youtu.be/MdgmyOHldZg

according to schematics charger is: ISL9519HRTZ-T_TQFN28_4X4

https://www.intersil.com/content/dam/intersil/documents/isl9/isl9519.pdf (too short, not useful)

There seems to be patch to add isl9519q to kernel back from 2011: https://lkml.org/lkml/2011/8/29/312
which judging from one datasheet that google can find {file: ISL9519C-Intersil.pdf} is roughly correct.

However, it's connected to KB930QF-A1_LQFP128_14X14 which seems to be bios controller chip based
on 8051 core with custom firmware and 2.6 driver is https://github.com/dpavlin/linux/blob/thinktabletopensource-2.6.36/drivers/power/EC_battery.c

^^^ turn charning on

After connecting usb, issue following command to start charging battery:

.pre
i2cset -y 5 0x58 0x5b 0x0001 w
.pre

^^ kernel 2.6

custom drivers: https://github.com/dpavlin/linux/tree/thinktabletopensource-2.6.36/drivers/phj00

^ i2c

^^ mainline 4.19

.pre
root@tegra20:~# i2cdetect -l     
i2c-3   i2c             7000d000.i2c                            I2C adapter
i2c-1   i2c             7000c400.i2c                            I2C adapter
i2c-4   i2c             i2c-1-mux (chan_id 0)                   I2C adapter
i2c-2   i2c             7000c500.i2c                            I2C adapter
i2c-0   i2c             7000c000.i2c                            I2C adapter
i2c-5   i2c             i2c-1-mux (chan_id 1)                   I2C adapter

root@tegra20:~# i2cdetect -y -r 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- UU -- 1c -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 1 # very slow
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- 0f 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 4
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# i2cdetect -y -r 5
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@tegra20:~# grep . /sys/bus/i2c/devices/*/name
/sys/bus/i2c/devices/0-001a/name:wm8903
/sys/bus/i2c/devices/0-0044/name:isl29018
/sys/bus/i2c/devices/3-0034/name:tps6586x
/sys/bus/i2c/devices/3-004c/name:nct1008
/sys/bus/i2c/devices/i2c-0/name:7000c000.i2c
/sys/bus/i2c/devices/i2c-1/name:7000c400.i2c
/sys/bus/i2c/devices/i2c-2/name:7000c500.i2c
/sys/bus/i2c/devices/i2c-3/name:7000d000.i2c
/sys/bus/i2c/devices/i2c-4/name:i2c-1-mux (chan_id 0)
/sys/bus/i2c/devices/i2c-5/name:i2c-1-mux (chan_id 1)


.pre

^^ kernel 2.6 (android)

.pre
shell@android:/ # grep . /sys/bus/i2c/devices/*/name                           
/sys/bus/i2c/devices/0-001a/name:wm8903
/sys/bus/i2c/devices/0-001c/name:al3000a_ls
/sys/bus/i2c/devices/1-003a/name:nvhdcp1
/sys/bus/i2c/devices/1-0050/name:tegra_edid
/sys/bus/i2c/devices/2-0050/name:phj00_lcd
/sys/bus/i2c/devices/2-0058/name:EC_Battery
/sys/bus/i2c/devices/3-003c/name:mt9p111
/sys/bus/i2c/devices/3-003d/name:mt9d115
/sys/bus/i2c/devices/4-000c/name:akm8975
/sys/bus/i2c/devices/4-000f/name:kxtf9
/sys/bus/i2c/devices/4-0034/name:tps6586x
/sys/bus/i2c/devices/4-004c/name:nct1008
/sys/bus/i2c/devices/i2c-0/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-1/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-2/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-3/name:Tegra I2C adapter
/sys/bus/i2c/devices/i2c-4/name:Tegra I2C adapter

shell@android:/sys/kernel/debug # grep . clock/i2c*/rate                       
clock/i2c1/rate:3000000
clock/i2c2/rate:800000
clock/i2c3/rate:3000000


.pre

^^ addresses from schematics

| PWR_I2C address |
| PMU | 0b0110_100 | 0x34 |
| E-Compass | 0b0000_110 | 0x06 |
| Temperature sensor | 0b0100_110 | 0x26 |
| GEN1_I2C |
| Audio Codec | 0b0011_010 | 0x1a |
| Light sensor | 0b0001_110 | 0x0e |
| EC_SMB |
| BATT | 0b0001_001 | 0x09 |
| IME_I2C |
| G-sensor | 0b0001_1111 | 0x1f |

does g-sensor have typo? 0b0001_111 is 0x0f and we see such device

^ [i2c] devices support

* [al3000a] i2c light sensor
* [phj00] include EC communication
{file: ESP32-Devkit-Pinout_19.pdf}

https://github.com/espressif/arduino-esp32/issues/544

^ ESP32 DEVKIT1

schematic: {file: SchematicsforESP32.pdf}

to get into bootloader mode (out of box) plug module in (red led will show that it has power from usb) and:

press EN - press BOOT - release EN - release BOOT

.pre
dpavlin@x200:/mnt/nuc/esptool$ ./esptool.py -p /dev/ttyUSB0 --chip esp32 read_mac
esptool.py v2.7-dev
Serial port /dev/ttyUSB0
Connecting........_
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 3c:71:bf:aa:fc:24
Uploading stub...
Running stub...
Stub running...
MAC: 3c:71:bf:aa:fc:24
Hard resetting via RTS pin...

dpavlin@x200:/mnt/nuc/esptool$ ./esptool.py -p /dev/ttyUSB0 --chip esp32 chip_id
esptool.py v2.7-dev
Serial port /dev/ttyUSB0
Connecting........__
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 3c:71:bf:aa:fc:24
Uploading stub...
Running stub...
Stub running...
Warning: ESP32 has no Chip ID. Reading MAC instead.
MAC: 3c:71:bf:aa:fc:24
Hard resetting via RTS pin...

dpavlin@x200:/mnt/nuc/esptool$ ./esptool.py -p /dev/ttyUSB0 --chip esp32 flash_id
esptool.py v2.7-dev
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____.
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 3c:71:bf:aa:fc:24
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

.pre

^ setup

https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html#setup-toolchain

.pre
dpavlin@nuc:/nuc/esp32$ wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

dpavlin@nuc:/nuc/esp32$ tar tvf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

dpavlin@nuc:/nuc/esp32$ git clone --recursive https://github.com/espressif/esp-idf.git

dpavlin@nuc:/nuc/esp32$ cd esp-idf/

dpavlin@nuc:/nuc/esp32/esp-idf$ cat env.sh 
export IDF_PATH=/nuc/esp32/esp-idf
export PATH=/nuc/esp32/xtensa-esp32-elf/bin/:$PATH
dpavlin@nuc:/nuc/esp32/esp-idf$ . env.sh 

dpavlin@nuc:/nuc/esp32/esp-idf$ python2 -m pip install --user -r $IDF_PATH/requirements.txt
Requirement already satisfied: setuptools in /usr/lib/python2.7/dist-packages (from -r /nuc/esp32/esp-idf/requirements.txt (line 4)) (40.6.2)
Requirement already satisfied: pyserial>=3.0 in /home/dpavlin/.local/lib/python2.7/site-packages (from -r /nuc/esp32/esp-idf/requirements.txt (line 8)) (3.4)
Requirement already satisfied: future>=0.15.2 in /usr/lib/python2.7/dist-packages (from -r /nuc/esp32/esp-idf/requirements.txt (line 9)) (0.15.2)
Requirement already satisfied: cryptography>=2.1.4 in /usr/lib/python2.7/dist-packages (from -r /nuc/esp32/esp-idf/requirements.txt (line 10)) (2.3)
Requirement already satisfied: pyparsing>=2.0.3 in /usr/lib/python2.7/dist-packages (from -r /nuc/esp32/esp-idf/requirements.txt (line 11)) (2.2.0)



.pre
I will try to collect useful info about Linux I2C infrastructure

* wirting regmap drivers https://opensourceforu.com/2017/01/regmap-reducing-redundancy-linux-code/
* Using the I2C-Stub to Emulate a Device https://eraretuya.github.io/2016/12/10/the-i2c-stub-in-action/
* very good overview of i2c and bus arbitration and testing https://elinux.org/images/c/c9/ELCE17-WSang-I2C-Fault-Injector.pdf
** https://www.youtube.com/watch?v=2UU_26rlJHs
{file: Tegra2_TRM_DP04508001v01p.pdf}

I will try to collect useful stuff about Tegra latest upstream source on this page.

^ Nvidia Tegra 2/3 APX/nv3p protocol implementation

* https://github.com/AndroidRoot/wheelie

^ qemu

https://github.com/digetx/tegra2_qemu

^ i2cdetect

.pre
root@ac100:~# i2cdetect -l
i2c-1   i2c             7000c400.i2c                            I2C adapter
i2c-2   i2c             7000d000.i2c                            I2C adapter
i2c-0   i2c             7000c000.i2c                            I2C adapter
root@ac100:~# i2cdetect -y 0                                                                                                                                                 
Error: Can't use SMBus Quick Write command on this bus                                                                                                                       
root@ac100:~# i2cdetect -F 0                                                                                                                                                 
Functionalities implemented by /dev/i2c-0:                                                                                                                                   
I2C                              yes                                                                                                                                         
SMBus Quick Command              no                                                                                                                                          
SMBus Send Byte                  yes                                                                                                                                         
SMBus Receive Byte               yes                                                                                                                                         
SMBus Write Byte                 yes                                                                                                                                         
SMBus Read Byte                  yes                                                                                                                                         
SMBus Write Word                 yes                                                                                                                                         
SMBus Read Word                  yes                                                                                                                                         
SMBus Process Call               yes                                                                                                                                         
SMBus Block Write                yes                                                                                                                                         
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        yes
I2C Block Write                  yes
I2C Block Read                   yes
root@ac100:~# i2cdetect -y -r 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 4f 
50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
.pre

^ grate-driver tegra2 support for mainline

https://github.com/grate-driver

https://github.com/grate-driver/grate/wiki/Grate-driver

.pre

https://wiki.debian.org/CreatePackageFromPPA

https://code.launchpad.net/~grate-driver/+archive/ubuntu/ppa

sudo apt install devscripts build-essential software-properties-common

sudo add-apt-repository ppa:grate-driver/ppa

# enable only deb-src (suggested beaver doesn't work for me)

root@tegra20:/home/dpavlin# cat /etc/apt/sources.list.d/grate-driver-ubuntu-ppa-disco.list 
#deb http://ppa.launchpad.net/grate-driver/ppa/ubuntu beaver main
deb-src http://ppa.launchpad.net/grate-driver/ppa/ubuntu disco main


apt update # make sure that is pass, use apt-key adv --recv-key if needed

# build order is important

apt-get build-dep libdrm
apt source --build libdrm
dpkg -i libdrm*.deb


apt-get build-dep xserver-xorg-video-opentegra

apt source --build xserver-xorg-video-opentegra

# this will fail to instal because of libturbojpg dependency

root@x200:/home/dpavlin/grade-build/xserver-xorg-video-opentegra-201901152016~grate~feac058~ubuntu19.04.1# vi debian/control

Package: xserver-xorg-video-opentegra
Architecture: armhf
Depends: ${shlibs:Depends}, ${misc:Depends}, ${xviddriver:Depends},
 libdrm-tegra0, liblz4-1, libturbojpeg0 (>= 1.5.0), libpng16-16,
Provides: ${xviddriver:Provides}
Description: X.Org X server -- Opensource driver for NVIDIA Tegra.
 This package provides HW-accelerated opensource driver for NVIDIA
 Tegra20+ SoC's from the GRATE project <URL:https://github.com/grate-driver>.


root@x200:/home/dpavlin/grade-build/xserver-xorg-video-opentegra-201901152016~grate~feac058~ubuntu19.04.1# dpkg-buildpackage



root@tegra20:/home/dpavlin# apt-get install x11-xserver-utils

root@tegra20:/etc# git diff
diff --git a/X11/xinit/xserverrc b/X11/xinit/xserverrc
index 94494ec..e6c4aa4 100755
--- a/X11/xinit/xserverrc
+++ b/X11/xinit/xserverrc
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-exec /usr/bin/X -nolisten tcp "$@"
+exec /usr/bin/X -listen tcp "$@"


# let's try it

startx

root@tegra20:/home/dpavlin# export DISPLAY=:0
root@tegra20:/home/dpavlin# xhost +
access control disabled, clients can connect from any host

# on another computer

dpavlin@x200:~$ x2x -to tegra20:0 -south


# and one flip of display later, I have working X11 with remote mouse and keyboard

root@tegra20:/home/dpavlin# xrandr --output LVDS-0 --rotation inverted


# to get mesa to compile beause of dependencies, I needed to update to buster

root@tegra20:/home/dpavlin# apt-get build-dep mesa
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 builddeps:mesa : Depends: debhelper (>= 11) but 10.2.5 is to be installed
                  Depends: quilt (>= 0.63-8.2~) but it is not going to be installed
                  Depends: x11proto-dev but it is not installable
                  Depends: libxcb-dri3-dev (>= 1.13) but it is not going to be installed
                  Depends: libxcb-present-dev (>= 1.13) but it is not going to be installed
                  Depends: llvm-7-dev (>= 1:7~) but it is not installable
                  Depends: libwayland-dev (>= 1.15.0) but 1.12.0-1 is to be installed
                  Depends: libwayland-egl-backend-dev (>= 1.15.0) but it is not installable
                  Depends: libclang-7-dev (>= 1:7~) but it is not installable
                  Depends: libclc-dev (>= 0.2.0+git20180917-1~) but it is not going to be installed
                  Depends: wayland-protocols (>= 1.9) but it is not going to be installed
                  Depends: libglvnd-core-dev but it is not installable
E: Unable to correct problems, you have held broken packages.


# after buster upgrade and rebuild of everything

(with dpkg-buildpackage)

root@tegra20:/home/dpavlin/grade-build# apt source --build mesa

dpkg -i *.deb

~50 fps with 25% cpu usage in glxgears


root@tegra20:/home/dpavlin/grade-build# apt-get build-dep libvdpau-tegra
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 builddeps:libvdpau-tegra : Depends: libdri2-dev but it is not installable
E: Unable to correct problems, you have held broken packages.


# sigh

root@tegra20:/home/dpavlin/grade-build# apt source --build libvdpau-tegra
...
dpkg-checkbuilddeps: error: Unmet build dependencies: libxv-dev libdri2-dev


root@tegra20:/home/dpavlin/grade-build# apt --fix-broken install
root@tegra20:/home/dpavlin/grade-build# apt-get install libxv-dev

root@tegra20:/home/dpavlin/grade-build/libvdpau-tegra-201901220047~grate~8efb41c~ubuntu18.10.1# vi debian/control 

remove libdri2-dev and libdri2

root@tegra20:/home/dpavlin/grade-build/libvdpau-tegra-201901220047~grate~8efb41c~ubuntu18.10.1# dpkg-buildpackage

dpkg -i ../libvdpau-tegra*.deb


.pre
[Lenovo Thinkpad Tablet]

{toc: }

^ EC_battery

https://github.com/dpavlin/linux/blob/thinktabletopensource-2.6.36/drivers/power/EC_battery.c

^^ battery info from shell

.pre
dpavlin@tegra20:~$ cat batt-info.sh 
#!/bin/sh

printf 'BatCapacity: %d %%\n' `i2cget -y 5 0x58 0x00 w`
printf 'BatFullCapacity:   %d\n' `i2cget -y 5 0x58 0x07 w`
printf 'BatDesignCapacity: %d\n' `i2cget -y 5 0x58 0x08 w`
printf 'ChargerStatus: %d\n' `i2cget -y 5 0x58 0x0b w`
printf 'UsbStatus: %d\n' `i2cget -y 5 0x58 0x5b w`

printf 'voltage: %d\n' `i2cget -y 5 0x58 0x01 w`
printf 'temperature: %d\n' `i2cget -y 5 0x58 0x0a w`

ec_status=`i2cget -y 5 0x58 0x0b w`
case $ec_status in
        0x0000) ec_status_dec="discharging" ;;
        0x0001) ec_status_dec="charging" ;;
        0x0002) ec_status_dec="full" ;;
        *) echo "unknown $ec_status" && exit 1
esac
printf 'EC_status: %d [%s]\n' $ec_status $ec_status_dec

dpavlin@tegra20:~$ sudo ./batt-info.sh 
BatCapacity: 29 %
BatFullCapacity:   2670
BatDesignCapacity: 3250
ChargerStatus: 1
UsbStatus: 0
voltage: 7477
temperature: 2912
EC_status: 1 [charging]

.pre

^^ kernel 2.6 /sys/EcControl

.pre
shell@android:/sys/EcControl # grep . *
AssetNumber:
BTMAC:6c71d912972f
BatCapacity:66
BatCtlDisable:BatCtlDisable
BatCtlEnable:0
BatCurrent:-21
BatDesignCapacity:3250
BatFullCapacity:2786
BatLifeTime:0
BatLock:ok
BatStatus:Charging
BatteryUpdateMode:-2
BoardID:-258
Brandname:ThinkPad Tablet
ChargeLED:ChargeLED
ChargerStatus:1
Coldboot:0
DeviceStatus:0000000000001000
ECFwStatus:aa
ECRead:0x0c12
ECWrite:ECWrite
ECflashMode:0
ECflashread:B
ECflashwrite:ECflashwrite
EcVer:3f001900
FactoryStatus:INAKRUIN
GPSPower:0
IMEIwithBarcode:ffffffffffffff15
LEDAndroidOff:LEDAndroidOff
MFGBuildDate:2012/10/31
MTMSN:����������������
ManufactureDate:ffff-ff-ff
MicSwitch:2
NBUsbChargingCurrent:65278
OffLED:OffLED
OriStsLED:OriStsLED
PassCode:ECEG
PlanarSN:11S63Y1836Z1ZLFT2A70PT
PowerLED:PowerLED
PsensorPower:2
RebootAfterEcUpdate:RebootAfterEcUpdate
RecoveryMode:RecoveryMode
Reset:Reset
Resume:0
SerialNumber:49834956515650807177804989678086
SerialNumberwithoutBarcode:����������������������
Shutdown:Shutdown
SkuNumber:003f
Suspend:Suspend
SysStatus:1
ThreeGPower:1
UUID:5668546668516867494852664949695065575056546755496857495057555070
UsbStatus:0
WIFIMAC:ffffffffffff
.pre

^^ shell i2c tests

Sensor is not detected in i2cdetect since it returns 00 as first byte.
Arbitration errors on this bus (which are probably caused caused by scanning
other side of i2c mux or parent i2c controller -- I have to re-check this)
break communication with EC.

.pre
linux-2.6/drivers/power/EC_battery.c



# ready?
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x48 w
0x0008
# ready = ret & 0x00000008;

# BatCtlEnable_show

root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x5b w
0x0000

# EcVer_show

root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x30 w
0x3f00
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x31 w
0x2100

# UUID_show

for(i=0;i<16;i++)
           {
               val32 = i2c_smbus_read_word_data(EC_Bat_device->client,0x60);
               val16 = val32 & 0x0000ffff;
               TransformToByte(val16, &val8[2*i], &val8[2*i+1]);
               msleep(10);
           }

root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5768
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x6668
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x6567
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5456
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5070
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5552
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5651
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5770
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x6948
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x4949
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x5549
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x6856
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x4966
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x4869
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x6965
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w
0x4854
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x60 w # 17 repeat?
0x5768


# BatCapacity_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x00 w
0x004d

# BatFullCapacity_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x07 w
0x0773

# BatDesignCapacity_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x08 w
0x0965

# BTMAC_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x62 w
0xbd9d
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x62 w
0x68ac
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x62 w
0x742f
## repeat?
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x62 w
0xbd9d

# ChargerStatus_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x0b w
0x0001

# UsbStatus_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x5b w
0x0000

# ECRead_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0xF1 w
0x0c12

# Shutdown_store
i2c_smbus_write_word_data(EC_Bat_device->client,0x52,0);

# Suspend_store
i2c_smbus_write_word_data(EC_Bat_device->client,0x53,0);

# Coldboot_store
Coldboot_val = buffer & 0x0000FFFF;
i2c_smbus_write_word_data(EC_Bat_device->client,0x55,Coldboot_val);

# Resume_store
Resume_val = buffer & 0x0000FFFF;
i2c_smbus_write_word_data(EC_Bat_device->client,0x56,Resume_val);

# RecoveryMode_store
i2c_smbus_write_word_data(EC_Bat_device->client,0x58,val);

# MicSwitch_store
//echo 0 > MicSwitch(front) ,  echo 1 > MicSwitch(back), echo 2 > MicSwitch(normal)
//echo 3 > MicSwitch(echo cancellation test), echo 4 > MicSwitch(disable echo cancellation)
i2c_smbus_write_word_data(EC_Bat_device->client,0x44,MicSwitch_val);

# ThreeGPower_store
//echo 1 > ThreeGPower(poweron) ,  echo 0 > ThreeGPower(poweroff), echo 2 > ThreeGPower(backtoOriginstate)
i2c_smbus_write_word_data(EC_Bat_device->client,0x45,ThreeGPower_val);

# enable_ThreeGPower
ThreeGPower_val = 1; # 1 = enable, 0 = disable
i2c_smbus_write_word_data(EC_Bat_device->client,0x45,ThreeGPower_val);

# SerialNumber_show
for(i=0;i<=7;i++) {
val32 = i2c_smbus_read_word_data(EC_Bat_device->client,0x66);
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 0
0x5451
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 1
0x5468
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 2
0x8048
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 3
0x5277
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 4
0x8290
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 5
0x5157
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 6
0x4956
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 7
0x4983
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x66 w # 0
0x5451

# SkuNumber_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x68 w
0xffff


# LEDAndroidOff_store
i2c_smbus_write_word_data(EC_Bat_device->client,0x5a,0);

# Reset_store
i2c_smbus_write_word_data(EC_Bat_device->client,0x54,0);
 
# BatCurrent_show
i2c_smbus_read_word_data(EC_Bat_device->client,0x03);
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x03 w
0xff43
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x03 w
0xff42

# BatLifeTime_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x70 w
0x0000

# BoardID_show
root@tegra20:/mnt/nuc/Tegra# i2cget -y 5 0x58 0x32 w
0xfefe


# GPSPower_store
#         if(GPS_val == 0)	OFF
i2c_smbus_write_word_data(EC_Bat_device->client,0x47,0);
# else if(GPS_val == 1)		ON
i2c_smbus_write_word_data(EC_Bat_device->client,0x4a,0);


# PsensorPower_store
//echo 0 > PsensorPower(off), echo 1 > PsensorPower(on), echo 2 > PsensorPower(normal control)
i2c_smbus_write_word_data(EC_Bat_device->client,0x4b, PsensorPower_val);
root@tegra20:/mnt/nuc/Tegra# i2cset -y 5 0x58 0x4b 0x1 w
.pre
^ Seven Segment Optical Character Recognition

https://github.com/jiweibo/SSOCR

^ Digitizes numbers from videos & images of seven segment displays

opencv + python: https://github.com/suyashkumar/seven-segment-ocr

.pre



dpavlin@x200:/mnt/nuc/seven-segment-ocr/seven-segment-ocr$ sudo apt-get install python-opencv python-matplotlib

dpavlin@x200:/mnt/nuc/seven-segment-ocr/seven-segment-ocr$ python seven_segment_ocr.py --video /dev/video1 --output /mnt/nuc/Tegra/usb-charging.txt --period 1
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Device or resource busy
VIDEOIO(cvCreateFileCapture_Images (filename)): raised C++ exception:


v4l2-ctl -d /dev/video0 --list-formats

dpavlin@x200:/mnt/nuc/seven-segment-ocr/seven-segment-ocr$ v4l2-ctl -d /dev/video1 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'YUYV' (YUYV 4:2:2)
        [1]: 'H264' (H.264, compressed)
        [2]: 'MJPG' (Motion-JPEG, compressed)


.pre
^ al3000a i2c light sensor

found in [Lenovo Thinkpad Tablet]

{toc}

alternative driver, different from one in 2.6 kernel, contains some registar names but not full description of values:

https://github.com/vhda/linux_kernel_TF101/blob/master/drivers/hwmon/al3000a.c

.pre
#define AL3000A_REG_CONFIGURATION 0x00
#define AL3000A_REG_TIMING_CONTROL 0x01
#define AL3000A_REG_ALS_CONTROL  0x02
#define AL3000A_REG_INTERRUPT_STATUS 0x03
#define AL3000A_REG_DATA 0x05
#define AL3000A_REG_ALS_WINDOW 0x08

#define AL3000A_MODE_POWER_UP 0
#define AL3000A_MODE_POWER_DOWN 2
#define AL3000A_MODE_RESET 3

#define AL3000A_OPERATION_ACTIVE 0
#define AL3000A_OPERATION_IDLE 3
.pre

^^ i2c usage

kernel 2.6 driver: https://github.com/dpavlin/linux/blob/thinktabletopensource-2.6.36/drivers/misc/al3000a.c

.pre
# al_init


	//F/W Initial Flow
	//Power Down & Idle
	ret = i2c_smbus_write_byte_data(client, 0x00, 0x0B);

	// Integration Cycle = 4; Integration Time = 100ms;
	// Interrupt trigger when lux detection has changed 4 times
	// at 100ms intervals.
	ret = i2c_smbus_write_byte_data(client, 0x01, 0x11);

	//AL3000A ADC resolution = 64 levels; Low lux threshold = 0
	ret = i2c_smbus_write_byte_data(client, 0x02, 0xA0);

	//ALS Window Loss = 0
	//It isn't covered by shell so no window loss, need to modify at DVT
	ret = i2c_smbus_write_byte_data(client, 0x08, 0x00);


	//Read Data to clear INT Flag
	ret = i2c_smbus_read_i2c_block_data(client, 0x05, 1, &data);


# ls_enable

		//Read Data to clear INT Flag
		i2c_smbus_read_i2c_block_data(client, 0x05, 1, &data);
		//Power Up & Enable ALS
		i2c_smbus_write_byte_data(client, 0x00, 0x00);

# ls_disable

		//Power Down & Idle
		i2c_smbus_write_byte_data(client, 0x00, 0x0B);


.pre

^^ re-create in shell

.pre
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x00
root@tegra20:/home/dpavlin# i2cset -y 0 0x1c 0x00 0 b
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x1f
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x1f
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cdump -y 0 0x1c
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
02: 00 11 a0 01 4a 01 00 00 00 ff ff ff ff ff ff ff    .???J?..........


.pre
https://github.com/leaflabs/maple/blob/master/maple-r5/maple-r5-schematic.pdf

{toc}

^ specification


STM32 F103RB: a 32-bit ARM Cortex M3 microprocessor
Clock Speed: 72 MHz
Operating Voltage: 3.3V
Input Voltage (recommended): 3.0V-12V
39 Digital I/O Pins (GPIO)
16 Analog Input Pins
12-bit ADC resolution (ADC)
15 PWM pins at 16-bit resolution (PWM)
Dedicated USB port for programming and communications (USB)
External JTAG interface (USB)
128 Flash and 20KB SRAM
64 Channel nested vector interrupt handler (including external interrupt on GPIO’s)
Integrated SPI (SPI)
Integrated I2C (I2C)
7 Channels of Direct Memory Access (DMA)
3 USART devices
Four 4-channel Timers (Timers)
Supplies up to 500mA @ 3.3v
Support for low power and sleep modes (<500uA)

^ serial flash

Press boot 0, press reset, release reset, release boot 0

.pre
dpavlin@nuc:/nuc/stm32$ git clone https://github.com/jsnyder/stm32loader

dpavlin@nuc:/nuc/stm32/stm32loader$ ./stm32loader.py -p /dev/ttyUSB0 
Bootloader version 22
Chip id: 0x410 (STM32 Medium-density)

dpavlin@nuc:/nuc/stm32/stm32loader$ ./stm32loader.py -p /dev/ttyUSB0 -e -w -v maple_rev5_boot20.bin
Bootloader version 22
Chip id: 0x410 (STM32 Medium-density)
Write 256 bytes at 0x8000000
Write 256 bytes at 0x8000100
...
.pre

^ maple boot loader

.pre
dpavlin@nuc:/nuc/stm32/stm32loader$ wget http://docs.leaflabs.com/static.leaflabs.com/pub/leaflabs/maple-bootloader/maple_boot.bin

dpavlin@nuc:/nuc/stm32/stm32loader$ ./stm32loader.py -p /dev/ttyUSB0 -e -w -v maple_boot.bin

.pre

^ STM32 Arduino upgrade

^^ bootloader

* https://github.com/rogerclarkmelbourne/STM32duino-bootloader

.pre

dpavlin@nuc:/nuc/stm32/stm32loader$ wget https://github.com/rogerclarkmelbourne/STM32duino-bootloader/raw/master/STM32F1/binaries/maple_rev5_boot20.bin

.pre

maple r5 is not reported with dfu-util

https://github.com/rogerclarkmelbourne/STM32duino-bootloader/pull/20

^^  build

.pre
dpavlin@nuc:/nuc/stm32/STM32duino-bootloader$ make maple-rev5

...

Copying to binaries folder

cp build/maple_boot.bin bootloader_only_binaries/maple_rev5_boot20.bin

.pre
How to setup netboot for u-boot easily...

To make this work, you need supported usb network card:

.pre
root@tegra20:/home/dpavlin# lsusb -d 0b95:7720
Bus 003 Device 002: ID 0b95:7720 ASIX Electronics Corp. AX88772
.pre

This card has to be enabled in {link: kernel setup} so that we can nfsboot from it!

{toc: }

^ network setup

.pre
root@x200:/export/tegra20# cat /etc/network/interfaces.d/enp0s25 
#auto enp0s25
#iface enp0s25 inet dhcp

auto enp0s25
iface enp0s25 inet static
        address 192.168.4.1
        netmask 255.255.255.0
        post-up iptables -t nat -A POSTROUTING -s 192.168.4.0/24 -o wls1 -j MASQUERADE


root@x200:/export/tegra20# grep tegra20 /etc/hosts
192.168.4.100   tegra20
.pre

^ dnsmasq (dhcp, tftp)

.pre
dpavlin@x200:~$ cat /etc/dnsmasq.d/dhcp.conf 

#interface=enp0s25

dhcp-range=192.168.4.50,192.168.4.150,12h

# this should be mac address of usb network adapter for target device
dhcp-host=00:14:d1:b0:63:1c,192.168.4.100


enable-tftp
#tftp-root=/srv/tftp

# Set the boot filename for netboot/PXE. You will only need
# this is you want to boot machines over the network and you will need
# a TFTP server; either dnsmasq's built in TFTP server or an
# external one. (See below for how to enable the TFTP server.)
#dhcp-boot=pxelinux.0

tftp-root=/export/tegra20
dhcp-boot=boot/boot.scr

log-queries
log-dhcp
.pre

^ nfs

apt-get install nfs-kernel-server

.pre
dpavlin@x200:~$ grep tegra20 /etc/exports 
/export/tegra20        192.168.4.0/24(rw,sync,no_root_squash,no_subtree_check,fsid=1)
.pre

^ u-boot

Name of u-boot script file was found by looking into dnsmasq log and deducing which files u-boot requests as
boot name, hence symlink.

.pre
dpavlin@x200:/export/tegra20$ ls -al boot.scr.uimg 
lrwxrwxrwx 1 dpavlin dpavlin 13 Jan 13 11:51 boot.scr.uimg -> boot/boot.scr


dpavlin@x200:/export/tegra20$ cat boot/boot.cmd

tftpboot ${kernel_addr_r} /boot/zImage
tftpboot ${fdt_addr_r} /boot/tegra20-ventana.dtb
tftpboot ${ramdisk_addr_r} /boot/uInitrd

setenv bootargs root=/dev/nfs nfsroot=192.168.4.1:/export/tegra20 ip=192.168.4.100:192.168.4.1:192.168.4.1:255.255.255.0:tegra20:eth0 panic=10 nfsrootdebug

#setenv bootargs ip=bootp root=/dev/nfs nfsroot=192.168.4.1:/export/tegra20 panic=10 nfsrootdebug init=/bin/sh

bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# mkimage -C none -A arm -T script -d boot.cmd boot.scr

.pre

ip=dhcp should work here, but doesn't for me, mostly because kernel tries to init dummy0 and wifi network first instead of eth0, so we never get successfully mounted nfsroot :-(

^ kernel setup

To make this work, kernel for target device also has to have usb network drivers built in (I did try with modules but in combination with Debian's initrd it will never boot).

I have following usb network configuration enabled:

.pre
dpavlin@klin:/klin/Tegra/linux$ grep USB_NET .config | grep -v ^#
CONFIG_USB_NET_DRIVERS=y
CONFIG_USB_NET_AX8817X=y
CONFIG_USB_NET_AX88179_178A=y
CONFIG_USB_NET_CDCETHER=y
CONFIG_USB_NET_CDC_NCM=y
CONFIG_USB_NET_SMSC75XX=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_USB_NET_NET1080=y
CONFIG_USB_NET_CDC_SUBSET_ENABLE=y
CONFIG_USB_NET_CDC_SUBSET=y
CONFIG_USB_NET_ZAURUS=y
.pre

^ links

* for beagle bone https://bootlin.com/blog/tftp-nfs-booting-beagle-bone-black-wireless-pocket-beagle/
{file: Pine64.txt}

{toc: }

^ board and pinouts info

* http://synfare.com/599N105E/hwdocs/pine64/index.html

^ armbian

After upgrade to armbian-next , it doesn't boot. Stop u-boot with space and boot manually:

.pre
# try to boot only from mmc
=> setenv bootcmd run mmc_boot
=> saveenv
Saving Environment to MMC...
Writing to MMC(0)... done

=> run mmc_boot
# this will fail, but will set some enviroment variables needed

=> setenv devtype mmc
=> setenv prefix /boot/
=> load ${devtype} 0 ${ramdisk_addr_r} ${prefix}uInitrd
4293052 bytes read in 676 ms (6.1 MiB/s)

=> load ${devtype} 0 ${kernel_addr_r} ${prefix}Image 
12957704 bytes read in 1386 ms (8.9 MiB/s)

=> load ${devtype} 0 ${fdt_addr_r} ${prefix}dtb/${fdtfile}
14505 bytes read in 397 ms (35.2 KiB/s)

=> booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# fix load addresses in /boot/boot.cmd
=> setenv fdt_addr ${fdt_addr_r}
=> setenv kernel_addr ${kernel_addr_r}
=> setenv ramdisk_addr ${ramdisk_addr_r}    
=> saveenv


.pre

fixed: {file: boot.cmd}

^ Links

http://wiki.pine64.org/index.php/Main_Page

http://linux-sunxi.org/Pine64

https://github.com/apritzel/pine64

Debian rootfs: https://github.com/umiddelb/z2d/tree/master/pine64

^ u-boot

https://github.com/longsleep/build-pine64-image

http://forum.pine64.org/showthread.php?tid=99

https://www.stdin.xyz/downloads/people/longsleep/pine64-images/

^ kernel

http://forum.pine64.org/showthread.php?tid=293

^^ serial ports

* https://github.com/longsleep/build-pine64-image/pull/11

* update image: http://forum.pine64.org/showthread.php?tid=99

* from http://linux-sunxi.org/Pine64#Serial_port_.2F_UART

{image: 800px-Pine64_UART0.jpg}
{file: Samsung_UExxEH45_53_ES55_57_58_U78A.pdf}

{file: Samsung шасси U71A, U71B.pdf}

{toc: }

^ service menu

https://wiki.samygo.tv/index.php?title=Service_Menu

Enter service menu: UE,LE models:[INFO] [MENU] [MUTE] [POWER]

This has to be pressed fast, within second or two. To disable sound, select HDMI input.

.pre
T-MST10PDEUC-2007.0
T-MST10PDEUS-1002
E-Manual:XTDVBEUE-1042

EDID SUCCESS
HDCP SUCCESS
CALIB: AV / COMP / PC / HDMI /
Option: 40A6AF0D,EU,5450,NONE
FactoryCS: 0x5ce5c95
T-MSXDEUCIP-1000

Onboot : 1003
SDAL-3.63.0.0
RFS:*X10P 0072
2016-04-01
FUNC-TAG-ERR

Type: 40A6AF0D
Model: UE40EH5450
Wired MAC ----
CIP SUCCESS
DRM : ----
Factory Data Ver : 216
EERC Version : 2124
DTP-AP-COMP-945-X10P_DEU-107
DTP-BP-HAL-0381-X10P_DEU-204-01
DTP-BP-0874-42
POP-FLA-12-0009.19
Date of purchase : 1/4/2019
.pre

Sigh, I did reset with default PIN 0000 before entering service menu, so counter and date is reset.

I also changed Control > Sub Option > RS-232 Jack -> Debug

^ Ex-Link Cable (service port TTL serial)

https://wiki.samygo.tv/index.php?title=Ex-Link_Cable_for_C/D/E_Series_and_BD_players

{image: 800px-TTL-232_E_pinout.jpg}

3.5mm jack "service" on TV:

* 1 - tip - Tx
* 2 - ring - Rx
* 3 - ring - GND

If you have TRRR jack, just use first three pins. Others are not connected to anything in TV.
To find ground pin check continuity between your jack breakout and USB connector. One you found
ground, pins from it towards tip are Rx and Tx.

I also measured Rx and Tx pins which where around 3.3V, so safe to connect to usb serial.

^^ dump of serial console

It's 115200 8n1 3.3V serial console:

{file: samsung-UE40EH5450-serial.txt.gz}

^ top-debug menu

https://wiki.samygo.tv/index.php?title=Top_Debug_Menu:_TDM

^^ Console unlock and TDM codes

MStar (Series 5 & 6):

1198282
20089999

Just blindly start typing numbers:

.pre
20089999
====================================
      [ TOP Debug Menu]
------------------------------------
  1  : SubSystem Print On/Off
  2  : Platform Print Setting
  3  : TD Print Setting
  4  : Performance Print Setting
  5  : Sdal Print Setting
  6  : Sdal Trace Setting
  11 : TD Debug
  12 : SubSystem DBG
  13 : SubSystem Info Print
  21 : Louvre Print Setting
  30 : Auto Lock DBG
------------------------------------
  70 : Jade Debug
  80 : PVR Debug
  81 : CSP debug
====================================
  99 : Exit
====================================
.pre

^ service manuals

http://tel-spb.ru/tv/samsung-ue40eh5450
{toc}

^ GONGJUE 8018LCD

* http://www.banggood.com/8018LCD-220V-450-Degree-LCD-Adjustable-Electronic-Heat-Hot-Air-Gun-p-970060.html

* https://www.youtube.com/watch?v=XsxOuK5ZzRI

^^ schematics

{image: schema_GJ_8018LCD.JPG}

^^ board

{image: board_GJ-8018LCD.png}

{file: Sprint-Layout60_Viewer.exe}

{file: HGunCJ8018LCD_ZRN.lay6}

* http://imgur.com/a/yyhHi


^ ideas for upgrade with mcu controll

* Arduino based hot air, similar to what we need: https://www.instructables.com/id/Cheap-Hot-Air-Station-With-Arduino/
* Alternative firmware for different station: https://github.com/madworm/Youyue-858D-plus
Connect external monitors to your system via Wifi-Display specification also known as Miracast

https://github.com/albfan/miraclecast/

{toc: }

Hostname is misleading, this is rpi3

.pre
root@rpi2:/nuc/miraclecast/res# tail -14 /proc/cpuinfo 

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : BCM2835
Revision        : a02082
Serial          : 000000004d092298
.pre

^ check wifi chipset compatibility

.pre

root@rpi2:/nuc/miraclecast/res# ./test-hardware-capabilities.sh 
wlan0 supports P2P

.pre

^ compile and install

.pre

root@rpi2:/nuc/miraclecast# git remote -v
origin https://github.com/albfan/miraclecast (fetch)
origin https://github.com/albfan/miraclecast (push)

pi@rpi2 /nuc/miraclecast $ sudo apt-get install libudev-dev libreadline-dev gstreamer1.0-tools

pi@rpi2 /nuc/miraclecast $

./autogen.sh c
make
sudo make install

.pre

^ connect from Android

.pre

root@rpi2:~# miracle-wifid --log-level trace &

root@rpi2:/home/pi/miraclecast# miracle-sinkctl 
[ADD] Link: 3
[miraclectl] # run 3
now running on link 3

.pre

try to connect from android phone and fail

.pre

[ADD] Peer: ce:fa:00:af:9a:5a@3
[PROV] Peer: ce:fa:00:af:9a:5a@3 Type: pbc PIN: 
[GO NEG] Peer: ce:fa:00:af:9a:5a@3 Type: pbc PIN: 
[GO NEG] Peer: ce:fa:00:af:9a:5a@3 Type: pbc PIN: 
[FAIL] Peer: ce:fa:00:af:9a:5a@3 Reason: group owner negotiation failed
[miraclectl] #

.pre
{image: n516950085_2337724_7335.jpg}

> Second try at buying USB TV card that *works* under Linux

And sure, 22 EUR later (chepest card in the shop which *included* remote) I had working DVB-T under Linux

{toc: }

^ Info

http://linuxtv.org/wiki/index.php/Hauppauge_WinTV-NOVA-T-Stick

^ Firmware

.pre
cd /lib/firmware/
wget http://www.wi-bw.tfh-wildau.de/~pboettch/home/linux-dvb-firmware/dvb-usb-dib0700-1.10.fw
.pre

^ info

.pre
dpavlin@t61p:~$ lsusb | grep Nova
Bus 002 Device 003: ID 2040:7070 Hauppauge Nova-T Stick 3
.pre

^ Zagreb frequencies

.pre
T 754000000 8MHz 2/3 NONE AUTO 8k 1/8 NONE    # CH27:
T 642000000 8MHz 2/3 NONE AUTO 8k 1/8 NONE    # CH27:
T 690000000 8MHz 2/3 NONE AUTO 8k 1/8 NONE    # CH27:
.pre

Feed that file to `scan` from `dvb-apps` to get output for mplayer's `channels.conf`

^ EeePC as TV for my mother

{fetchrss: http://svn.rot13.org/index.cgi/mplayer-eee-tv/rss full}

^ dmesg

.pre
[352538.540055] usb 3-1.1: new high-speed USB device number 32 using ehci-pci
[352538.648944] usb 3-1.1: New USB device found, idVendor=2040, idProduct=7070, bcdDevice= 1.00
[352538.648951] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[352538.648956] usb 3-1.1: Product: Nova-T Stick
[352538.648960] usb 3-1.1: Manufacturer: Hauppauge
[352538.648964] usb 3-1.1: SerialNumber: 4032258708
[352538.682065] dvb-usb: found a 'Hauppauge Nova-T Stick' in cold state, will try to load a firmware
[352538.682869] usb 3-1.1: firmware: direct-loading firmware dvb-usb-dib0700-1.20.fw
[352538.885559] dib0700: firmware started successfully.
[352539.420241] dvb-usb: found a 'Hauppauge Nova-T Stick' in warm state.
[352539.420476] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[352539.420571] dvbdev: DVB: registering new adapter (Hauppauge Nova-T Stick)
[352539.664695] usb 3-1.1: DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)...
[352539.903507] dib0070: DiB0070: successfully identified
[352539.936061] Registered IR keymap rc-dib0700-rc5
[352539.936410] rc rc0: Hauppauge Nova-T Stick as /devices/pci0000:00/0000:00:1d.0/usb3/3-1/3-1.1/rc/rc0
[352539.936486] input: Hauppauge Nova-T Stick as /devices/pci0000:00/0000:00:1d.0/usb3/3-1/3-1.1/rc/rc0/input13
[352539.936674] rc rc0: lirc_dev: driver dib0700 registered at minor = 0, scancode receiver, no transmitter
[352539.936678] dvb-usb: schedule remote query interval to 50 msecs.
[352539.936682] dvb-usb: Hauppauge Nova-T Stick successfully initialized and connected.
[352539.936876] usbcore: registered new interface driver dvb_usb_dib0700


.pre

^ scan

* https://www.linuxtv.org/wiki/index.php/Scan
* https://www.linuxtv.org/wiki/index.php/Testing_your_DVB_device

.pre

dpavlin@klin:~$ mkdir ~/.{a,c,s,t}zap


dpavlin@klin:~$ scan -v /usr/share/dvb/dvb-legacy/dvb-t/hr-All > .tzap/channels.conf

dumping lists (4 services)
[0015]:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:2011:2012:21
[0016]:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:2021:2022:22
[0017]:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:2031:2032:23
[0018]:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:2041:2042:24

dpavlin@klin:~$ /usr/bin/tzap -r -c ~/.tzap/channels.conf "[0018]"
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/home/dpavlin/.tzap/channels.conf'
Version: 5.11    FE_CAN { DVB-T }
tuning to 690000000 Hz
video pid 0x07f9, audio pid 0x07fa
status 0f | signal 9dca | snr 00ad | ber 001fffff | unc 00000000 | 
status 1f | signal 9cd0 | snr 00bc | ber 000060a0 | unc 00000000 | FE_HAS_LOCK

dpavlin@klin:~$ mplayer /dev/dvb/adapter0/dvr0

.pre
{file: PrintrBot_Plus_LC.diff}

Old 3D printer which never worked well.

DXF files: https://www.youmagine.com/designs/printrbot-lc-1302

https://web.archive.org/web/20130115210644/http://printrbot.com/shop/plus/

{toc: }

^ PrintrBot Plus LC

The Printrbot PLUS is the larger printrbot kit–containing an 8x8x8 build volume, laser cut birch construction, an assembled Ubis hot end, and 12mm Z-axis rods in an all-in-one kit. This kit also includes 1 lb of ABS filament.

This kit includes everything you need to build the printrbot PLUS:

* printrboard: all-in-one assembled electronics with integrated SD card slot (no soldering required)
* 5 NEMA 17 stepper motors complete with cable ends attached
* laser cut birch construction
* a few printed plastic parts (gears, etc)
* WOOD Extruder Kit
* hardware (8mm smooth rods, threaded rods, and bearings
** Z axis is 12mm smooth rods and 12 mm linear bearings )
* assembled Ubis hot end
* nuts, bolts, washers, zip ties
* laser cut print bed
* 8×8 heated bed
* misc assembled cables (no soldering required)
* 3 mechanical end stops (no soldering required)
* micro USB cable

^^ nozzle

The Getting Started Guide says that all Printrbots currently ship with 0.4mm nozzles.
The convention for identifying nozzles is based on notches (or "rings") cut into the sides (vertices) of the hexagonal brass "nut".
No notch = 0.5mm
1 notch = 0.4mm
2 notches = 0.35mm

^ info

Most of information about it vanished from internet so here is some overview:

* http://reprap.org/wiki/Printrbot
* http://reprap.org/wiki/Printrboard

* https://github.com/Printrbot/printrboard

Rev.B https://github.com/Printrbot/printrboard/releases/tag/revB

^ PrintrBoard pinout

Annotated headers from http://blog.think3dprint3d.com/2012/07/panelolu-with-printrboard.html

{image: Printrboard Headers.JPG}

^ serial

.pre
[Sun Mar 18 08:23:50 2018] usb 2-4.4: new full-speed USB device number 61 using xhci_hcd
[Sun Mar 18 08:23:50 2018] usb 2-4.4: New USB device found, idVendor=16c0, idProduct=0483
[Sun Mar 18 08:23:50 2018] usb 2-4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Sun Mar 18 08:23:50 2018] usb 2-4.4: Product: USB Serial
[Sun Mar 18 08:23:50 2018] usb 2-4.4: Manufacturer: Teensyduino
[Sun Mar 18 08:23:50 2018] usb 2-4.4: SerialNumber: 12345
[Sun Mar 18 08:23:50 2018] cdc_acm 2-4.4:1.0: ttyACM0: USB ACM device

dpavlin@nuc:~$ microcom p /dev/ttyACM0 
connected to /dev/ttyACM0
Escape character: Ctrl\
Type the escape character to get to the prompt.


start
echo:PowerUp
 Brown out Reset
Marlin: 1.0.0 RC2
echo: Last Updated: 2012-02-25 | Author: erik
echo: Free Memory: 4907  Pla




echo:SD init fail
workDir open failed
echo:Unknown command:"echo"
ok
echo:Unknown command:"SD init fail"
ok
echo:Unknown command:"workDir open failed"
ok
.pre

^ settings

https://github.com/Printrbot/Marlin

.pre
M501
echo:Stored settings retreived:
echo:Steps per unit:
echo:  M92 X62.11 Y64.67 Z2272.72 E536.00
echo:Maximum feedrates (mm/s):
echo:  M203 X60.00 Y60.00 Z2.00 E14.00
echo:Maximum Acceleration (mm/s2):
echo:  M201 X2000 Y2000 Z30 E10000
echo:Acceleration: S=acceleration, T=retract acceleration
echo:  M204 S3000.00 T3000.00
echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s),  Z=maximum Z jerk (mm/s)
echo:  M205 S0.00 T0.00 B20000 X20.00 Z0.40 E5.00
echo:PID settings:
echo:   M301 P22.20 I1.08 D114.00

M115
FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1

.pre

If this doesn't work, you can try `M503` which should display all settings without loading them from flash.

^ software bed leveler

* https://github.com/emard/zleveler

^ schematics

{file: Printrboard_RevB_Schematic150.png}

{file: Printrboard-schematics.pdf}

^ Marlin

* https://github.com/MarlinFirmware/Marlin
* http://marlinfw.org/meta/gcode/

.pre
dpavlin@nuc:/nuc/PrintrBot$ git clone https://github.com/dpavlin/Marlin

dpavlin@nuc:/nuc/PrintrBot$ cd Marlin/
.pre

^^ compile Marlin 1.1.8

https://github.com/dpavlin/Marlin/tree/PrintrBot_Plus_LC-1.1.8

.pre
dpavlin@nuc:/nuc/PrintrBot/Marlin$ git checkout PrintrBot_Plus_LC-1.1.8 

dpavlin@nuc:/nuc/PrintrBot/Marlin$ platformio run -e printrboard
Warning! Ignore unknown `envs_dir` option in `[platformio]` section

Processing printrboard (platform: teensy; board: teensy20pp; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Teensy > Teensy++ 2.0
SYSTEM: AT90USB1286 16MHz 8KB RAM (127KB Flash)
.pre

^^ compile Marlin 1.1.9

different enviroment compared to 1.1.8?

.pre
dpavlin@nuc:/nuc/PrintrBot/Marlin$ git checkout PrintrBot_Plus_LC-1.1.9 

dpavlin@nuc:/nuc/PrintrBot/Marlin$ platformio run -e teensy20
.pre

^^ flashing

open boot jumper, press button

.pre
[Sun Apr 15 12:20:34 2018] usb 1-1.1: new full-speed USB device number 30 using xhci_hcd
[Sun Apr 15 12:20:34 2018] usb 1-1.1: unable to get BOS descriptor
[Sun Apr 15 12:20:34 2018] usb 1-1.1: New USB device found, idVendor=03eb, idProduct=2ffb
[Sun Apr 15 12:20:34 2018] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Sun Apr 15 12:20:34 2018] usb 1-1.1: Product: AT90USB128 DFU
[Sun Apr 15 12:20:34 2018] usb 1-1.1: Manufacturer: ATMEL
[Sun Apr 15 12:20:34 2018] usb 1-1.1: SerialNumber: 1.0.0


root@nuc:/nuc/PrintrBot/Marlin# apt-get install dfu-programmer


root@nuc:/nuc/PrintrBot/Marlin# dfu-programmer --targets 2>&1 | grep at90usb128
    at89c5132          at90usb1287        at90usb1286        at90usb1287-4k
    at90usb1286-4k     at90usb647         at90usb646         at90usb162

root@nuc:/nuc/PrintrBot/Marlin# dfu-programmer at90usb1286 dump --debug 99
     target: at90usb1286
    chip_id: 0x2ffb
  vendor_id: 0x03eb
    command: dump
      quiet: false
      debug: 99
device_type: AVR
------ command specific below ------

commands.c:625: dump 122880 bytes
atmel.c:579: atmel_read_flash( 0x7ffe83facaf0, 0x00000000, 0x0001e000, 0x564ef5df7000, 122880, false )
atmel.c:847: atmel_select_page( 0x7ffe83facaf0, 0 )
atmel.c:510: __atmel_read_page( 0x7ffe83facaf0, 0, 65536, 0x564ef5df7000, false )
atmel.c:537: result: -9
Unknown error.  Try enabling debug.
Failed to read 122880 bytes from device.



.pre

other useful debug levels are 100, 200, 300 - https://www.avrfreaks.net/forum/how-use-dfu-programmer

hmmm... can't backup firmware?

^^ flash firmware

.pre
dpavlin@nuc:/nuc/PrintrBot/Marlin$ dfu-programmer at90usb1286 erase
dpavlin@nuc:/nuc/PrintrBot/Marlin$ dfu-programmer at90usb1286 flash .pioenvs/printrboard/firmware.hex
Validating...
Flash did not validate. Did you erase first?

dpavlin@nuc:/nuc/PrintrBot/Marlin$ dfu-programmer at90usb1286 erase --debug 100
     target: at90usb1286
    chip_id: 0x2ffb
  vendor_id: 0x03eb
    command: erase
      quiet: false
      debug: 100
device_type: AVR
------ command specific below ------
   validate: true

commands.c:69: erase 122879 bytes
atmel.c:281: atmel_erase_flash( 0x7ffc5df9bff0, 4 )
atmel.c:671: atmel_blank_check( 0x7ffc5df9bff0, 0x00000000, 0x0001dfff )
atmel.c:847: atmel_select_page( 0x7ffc5df9bff0, 0 )
atmel.c:647: __atmel_blank_check_internal( 0x7ffc5df9bff0, 0x00000000, 0x0000ffff )
atmel.c:847: atmel_select_page( 0x7ffc5df9bff0, 1 )
atmel.c:647: __atmel_blank_check_internal( 0x7ffc5df9bff0, 0x00000000, 0x0000dfff )

.pre

^^ teensy setup pjrc

udev rule: https://www.pjrc.com/teensy/49-teensy.rules
loader: https://github.com/PaulStoffregen/teensy_loader_cli

^^ unlock chip using flip

It seems that chip is protected. However, trying to erase and program it did destry data in it (expect bootloader) for some reason, and it seem that dfu-programmer doesn't know how to work with protection features.

So, next step is to try atmel's flip under linux but this also doesn't work well.

* patch path to /dev/bus/usb/ - https://www.avrfreaks.net/forum/instructions-get-batchisp-working-ubuntu-lucid-1004?name=PNphpBB2&file=viewtopic&t=97673

.pre
root@nuc:/nuc/PrintrBot/flip.3.2.1# cat debian-install.sh 
sudo apt-get install openjdk-9-jre:i386 libusb-0.1-4:i386

root@nuc:/nuc/PrintrBot/flip.3.2.1# cat env.sh 
export JAVA_HOME=/usr/lib/jvm/java-9-openjdk-i386/
export FLIP_HOME=/nuc/PrintrBot/flip.3.2.1/bin/


root@nuc:/nuc/PrintrBot/flip.3.2.1# cd bin/
root@nuc:/nuc/PrintrBot/flip.3.2.1/bin# cp -apv libatlibusbdfu.so libatlibusbdfu.so.orig
root@nuc:/nuc/PrintrBot/flip.3.2.1/bin# sed 's/\/sys\/bus\/usb/\/dev\/bus\/usb/g' libatlibusbdfu.so.orig > libatlibusbdfu.so


# run from bin directory or it won't work (?!)

root@nuc:/nuc/PrintrBot/flip.3.2.1/bin# ./flip.sh

.pre

^ avrdude

made cable to convert 10 pin ICSP on usbasp to 6 pin ICSP on printrboard

http://reprap.org/wiki/Printrboard#Bootloaders

Pin 1 (not red wire on my harness because of re-wiring) is closest to the SD card slot.

.pre
root@nuc:/nuc/PrintrBot# avrdude -p usb1286 -c usbasp 

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9782 (probably usb1287)

avrdude: safemode: Fuses OK (E:F3, H:99, L:5E)

avrdude done.  Thank you.
.pre

ok, factory bootloader

^^ fuses

.pre
# disable jtag
avrdude -c usbtiny -p at90usb1286 -U lfuse:w:0xde:m -U hfuse:w:0xdb:m -U efuse:w:0xf0:m

# enabled jtag
avrdude -c usbtiny -p at90usb1286 -U lfuse:w:0xDE:m -U hfuse:w:0x9B:m -U efuse:w:0xF0:m

root@nuc:/nuc/PrintrBot# avrdude -c usbtiny -p at90usb1286 -U lfuse:w:0xde:m -U hfuse:w:0xdb:m -U efuse:w:0xf0:m
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)

avrdude done.  Thank you.

root@nuc:/nuc/PrintrBot# avrdude -c usbasp -p at90usb1286 -U lfuse:w:0xde:m -U hfuse:w:0xdb:m -U efuse:w:0xf0:m

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9782 (probably usb1287)
avrdude: reading input file "0xde"
avrdude: writing lfuse (1 bytes):

Writing |                                                    | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.06s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xde:
avrdude: load data lfuse data from input file 0xde:
avrdude: input file 0xde contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x5e != 0xde
avrdude: verification error; content mismatch

avrdude: safemode: lfuse changed! Was de, and is now 5e
[Tue Apr 17 07:12:19 2018] usb 1-1.4: USB disconnect, device number 20
[Tue Apr 17 07:12:19 2018] usb 1-1.4: USB disconnect, device number 20
Would you like this fuse to be changed back? [y/n]
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK (E:F3, H:99, L:DE)

avrdude done.  Thank you.


root@nuc:/nuc/PrintrBot# avrdude -p usb1286 -c usbasp 

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9782 (probably usb1287)

avrdude: safemode: Fuses OK (E:F3, H:99, L:5E)

avrdude done.  Thank you.

.pre

^^ flash bootloader

huh, hum, program bootloader anyway from http://blog.lincomatic.com/?p=548

.pre
root@nuc:/nuc/PrintrBot# avrdude -p usb1286 -c usbasp -U flash:w:BootloaderDFU.hex
.pre

power cycle, return jumper re-try programming fuses

.pre
root@nuc:/nuc/PrintrBot# avrdude -c usbasp -p at90usb1286 -U lfuse:w:0xDE:m -U hfuse:w:0x9B:m -U efuse:w:0xF0:m
.pre

^^ dfu programming works

re-try dfu programming

.pre
root@nuc:/nuc/PrintrBot# dfu-programmer at90usb1286 erase
root@nuc:/nuc/PrintrBot# dfu-programmer at90usb1286 flash Marlin/.pioenvs/printrboard/firmware.hex
Validating...
61322 bytes used (49.90%)


.pre

^^ avrdude programming

.pre
dpavlin@nuc:/nuc/PrintrBot/Marlin$ avrdude -c usbasp -p usb1286 -U flash:w:.pioenvs/printrboard/firmware.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9782 (probably usb1287)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file ".pioenvs/printrboard/firmware.hex"
avrdude: input file .pioenvs/printrboard/firmware.hex auto detected as Intel Hex
avrdude: writing flash (87280 bytes):

Writing | ################################################## | 100% 58.04s

avrdude: 87280 bytes of flash written
avrdude: verifying flash memory against .pioenvs/printrboard/firmware.hex:
avrdude: load data flash data from input file .pioenvs/printrboard/firmware.hex:
avrdude: input file .pioenvs/printrboard/firmware.hex auto detected as Intel Hex
avrdude: input file .pioenvs/printrboard/firmware.hex contains 87280 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 38.49s

avrdude: verifying ...
avrdude: 87280 bytes of flash verified

avrdude: safemode: Fuses OK (E:F0, H:9B, L:DE)

avrdude done.  Thank you.
.pre

^ RepRapDiscount Full Graphic Smart Controller

* http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller

^^ pinouts

{file: printrboard-lcd-pinout.png}

{image: printrboard-lcd-pinout-800px.png}

^^ Marlin pinout

.pre
diff --git a/Marlin/pins_PRINTRBOARD.h b/Marlin/pins_PRINTRBOARD.h
index 42632d174..8146505a3 100644
--- a/Marlin/pins_PRINTRBOARD.h
+++ b/Marlin/pins_PRINTRBOARD.h
@@ -166,3 +166,19 @@
   #endif
 
 #endif // ULTRA_LCD && NEWPANEL
+
+// XXX dpavlin -- my pinout
+#define LCD_PINS_RS       9   // E1       JP11-11
+#define LCD_PINS_ENABLE   8   // E0       JP11-10
+#define LCD_PINS_D4       7   // D7       JP11-8
+#define LCD_PINS_D5       6   // D6       JP11-7
+#define LCD_PINS_D6       5   // D5       JP11-6
+#define LCD_PINS_D7       4   // D4       JP11-5
+
+#define BTN_EN1        10   // C0       JP11-12
+#define BTN_EN2        11   // C1       JP11-13
+#define BTN_ENC        12   // C2       JP11-14
+
+// display delays are added to
+// Marlin/ultralcd_st7920_u8glib_rrd.h
+
diff --git a/Marlin/ultralcd_st7920_u8glib_rrd.h b/Marlin/ultralcd_st7920_u8glib_rrd.h
index db6224e47..8474bef24 100644
--- a/Marlin/ultralcd_st7920_u8glib_rrd.h
+++ b/Marlin/ultralcd_st7920_u8glib_rrd.h
@@ -49,7 +49,7 @@
   #define CPU_ST7920_DELAY_1 DELAY_NS(0)
   #define CPU_ST7920_DELAY_2 DELAY_NS(0)
   #define CPU_ST7920_DELAY_3 DELAY_NS(50)
-#elif MB(3DRAG) || MB(K8200) || MB(K8400) || MB(SILVER_GATE)
+#elif MB(3DRAG) || MB(K8200) || MB(K8400) || MB(SILVER_GATE) || MB(PRINTRBOARD)
   #define CPU_ST7920_DELAY_1 DELAY_NS(0)
   #define CPU_ST7920_DELAY_2 DELAY_NS(188)
   #define CPU_ST7920_DELAY_3 DELAY_NS(0)
.pre

^ Hardware upgrade

^^ RAMPS1.4 LCD 12864

* RAMPS1.4 LCD 12864 Control Panel 3D Printer Smart Controller LCD Display $10
** https://www.aliexpress.com/item/1-pcs-RAMPS1-4-LCD-12864-Control-Panel-3D-Printer-Smart-Controller-LCD-Display-Free-Shipping/32312042967.html
** $10 - works well, needs custom cable, well worth it from usability perspective

^^ LM8UU

* 10pcs/lot LM8UU Ball Bearings 8mm Bushing For CNC 3D Printers Parts Rail Linear Long Rod Shaft Part 8mm*15mm*24mm Aluminum Bush
** https://www.aliexpress.com/item/10pcs-lot-LM8UU-Ball-Bearings-8mm-Bushing-For-CNC-3D-Printers-Parts-Rail-Linear-Long-Rod/32834729285.html
** $4.24 - NOT recomended, worse that original VXB.com -- seller specified brand as FYSETC, parts don't have any markings

^^ Y axis coupler

* 3D Printer Parts Accessory Stepper Motor Aluminum Alloy Z Axis Flexible Coupling Coupler Shaft Couplings 5mm*8mm*25mm
** https://www.aliexpress.com/item/10pcs-lot-LM8UU-Ball-Bearings-8mm-Bushing-For-CNC-3D-Printers-Parts-Rail-Linear-Long-Rod/32834729285.html
** $0.75 - NOT for Y axis, since they are flexible
* 3D Printer Blue Aluminum Alloy Coupler for 5 x 5mm/5 x 8mm Shaft for Stepper Motor Shaft
** https://www.aliexpress.com/item/3D-Printer-Blue-Aluminum-Alloy-Coupler-for-5-x-5mm-5-x-8mm-Shaft-for-Stepper/32854452012.html
** $0.71 - great, much better than 3d printed part

^^ belts and pulleys

* 2pcs GT2 20teeth 20 Teeth Bore 5mm/8mm Timing Alumium Pulley + 2Meters Rubber GT2-6mm Open Timing Belt Width 6mm for 3D Printer
** https://www.aliexpress.com/item/2Pcs-GT2-20teeth-20-Teeth-Bore-5mm-8mm-Timing-Alumium-Pulley-2Meters-Rubber-GT2-6mm-Open/32711078503.html
** $1.90 - great, pully nut doesn't interfere with clip which is holding glass since nut is flush as opposed to 3d printed part

^^ Y axes rod

* T8 Lead Screw OD 8mm Pitch 2mm Lead 2mm 150mm 200mm 250mm 300mm 350mm 400mm 500mm with Brass Nut for Reprap 3D Printer Z Axis
** 250mm with Nut
** https://www.aliexpress.com/item/T8-Lead-Screw-Rod-OD-8mm-Pitch-2mm-Lead-2mm-Length-150mm-500mm-Threaded-Rods-with/32760102869.html
** $5.14 x 2 - great, our rods where bent from out of box

Needs 3d printed adapter for nut to fit: https://www.thingiverse.com/thing:2963508

Nut is friction fit which I consider somewhat as safety feature, if I found problems with it, I will probably add a bit of ABS goo in holes to fix it in place

^^ bed leveling

self-made sensor from RFID card, paper clip and case intrusion switch, connected in parallel with z-axis switch (it has to be normally closed, so that trigger interrupts signal)

^ BL touch

* 1 Set Newest BL Touch Auto Bed Leveling Sensor 3D Touch Auto Leveling Sensor For Anet A8 3D Printer Improve Printing Precision
** https://www.aliexpress.com/store/product/1-Set-Newest-BL-Touch-Auto-Bed-Leveling-Sensor-3D-Touch-for-3D-Printer-Improve-Printing/3108017_32837521614.html

http://www.geeetech.com/wiki/index.php/3DTouch_Auto_Leveling_Sensor

pinout, right to left

| pin | wire color | board label |
| 5 | green | G |
| 4 | red | 5V |
| 3 | yellow | S |
| 2 | black | G |
| 1 | white | Z- |

Needs additional pin for servo control (S - servo)

^^ Marlin configuration

.pre
commit 18396a8cd25585d5d562d4345ed851b91fb58821 (HEAD -> PrintrBot_Plus_LC-1.1.9)
Author: Dobrica Pavlinusic <dpavlin@rot13.org>
Date:   Sat Sep 8 11:05:54 2018 +0200

    probe offset from extruder

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 438494220..aeed322a7 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -770,8 +770,8 @@
  *      O-- FRONT --+
  *    (0,0)
  */
-#define X_PROBE_OFFSET_FROM_EXTRUDER 10  // X offset: -left  +right  [of the nozzle]
-#define Y_PROBE_OFFSET_FROM_EXTRUDER 10  // Y offset: -front +behind [the nozzle]
+#define X_PROBE_OFFSET_FROM_EXTRUDER 35  // X offset: -left  +right  [of the nozzle]
+#define Y_PROBE_OFFSET_FROM_EXTRUDER 5   // Y offset: -front +behind [the nozzle]
 #define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]
 
 // Certain types of probes need to stay away from edges

commit 2329e561e0f2997e78495c249706e9ce62608293
Author: Dobrica Pavlinusic <dpavlin@rot13.org>
Date:   Sat Sep 8 10:51:07 2018 +0200

    enable bed leveling
    
    AUTO_BED_LEVELING_UBL doesn't seem to compile for me ATM

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 38e0c343b..438494220 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -969,7 +969,7 @@
  */
 //#define AUTO_BED_LEVELING_3POINT
 //#define AUTO_BED_LEVELING_LINEAR
-//#define AUTO_BED_LEVELING_BILINEAR
+#define AUTO_BED_LEVELING_BILINEAR
 //#define AUTO_BED_LEVELING_UBL
 //#define MESH_BED_LEVELING
 
@@ -1023,6 +1023,8 @@
   //#define FRONT_PROBE_BED_POSITION MIN_PROBE_EDGE
   //#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - MIN_PROBE_EDGE)
 
+  #define RIGHT_PROBE_BED_POSITION 190 // dpavlin -- probe overhangs on the right
+
   // Probe along the Y axis, advancing X after each column
   //#define PROBE_Y_FIRST
 

commit b867a948cd3b64d69e900b99a1306631d62753df
Author: Dobrica Pavlinusic <dpavlin@rot13.org>
Date:   Sun Sep 2 08:40:52 2018 +0200

    added bltouch config and pin on e-stop

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index fd8463456..38e0c343b 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -721,7 +721,7 @@
 /**
  * The BLTouch probe uses a Hall effect sensor and emulates a servo.
  */
-//#define BLTOUCH
+#define BLTOUCH
 #if ENABLED(BLTOUCH)
   //#define BLTOUCH_DELAY 375   // (ms) Enable and increase if needed
 #endif
@@ -1909,7 +1909,7 @@
  * Set this manually if there are extra servos needing manual control.
  * Leave undefined or set to 0 to entirely disable the servo subsystem.
  */
-//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
+#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command
 
 // Delay (in milliseconds) before the next move will start, to give the servo time to reach its target angle.
 // 300ms is a good value but you can try less delay.
diff --git a/Marlin/pins_PRINTRBOARD.h b/Marlin/pins_PRINTRBOARD.h
index 8146505a3..a68802725 100644
--- a/Marlin/pins_PRINTRBOARD.h
+++ b/Marlin/pins_PRINTRBOARD.h
@@ -182,3 +182,9 @@
 // display delays are added to
 // Marlin/ultralcd_st7920_u8glib_rrd.h
 
+// bltouch - use e-stop for servo
+// dpavlin@nuc:/nuc/PrintrBot/Marlin$ grep E5 m43-pins.txt 
+// PIN:  37   Port: E5        <unused/unknown>            Input  = 1
+//
+#define SERVO0_PIN	37	// E5 E-STOP
+
.pre

^^ gcode for bl-touch

M280 P0 S10 ; pushes the pin down

M280 P0 S90 ; pulls the pin up

M280 P0 S120 ; Self test – keeps going until you do pin up/down or release alarm

M280 P0 S160 ; Release alarm

M420 V ; display bed leveling

.pre
Bilinear Leveling Grid:
      0      1      2
 0 +0.445 +0.402 +0.284
 1 -0.083 +0.013 +0.023
 2 -0.678 -0.432 -0.264

echo:Bed Leveling On 
echo:Fade Height Off
.pre

----

^ Notes for Ender 3 V1.1.3

* install sanguino board support in ardunino ide https://github.com/Lauszus/Sanguino
* turn on power supply when flashing if you didn't disconnect steppers or it won't get enough power
* burn boot loader using usbasp programmer from arduino ide to make arudino ide work for upload
{file: Compal_LA-6352P_PAZ00_AC100.pdf}

{toc: }

[Tegra] 2 device

^ kernel

* https://gitlab.com/groups/ac100 (gitorious is dead)

^ cpuinfo

.pre
$ cat /proc/cpuinfo
Processor       : ARMv7 Processor rev 0 (v7l)
processor       : 0
BogoMIPS        : 1998.84

Features        : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x1
CPU part        : 0xc09
CPU revision    : 0

Hardware        : NVIDIA Harmony Development System
Revision        : 0000
Serial          : 0000000000000000

$ cat /proc/meminfo
MemTotal:         383348 kB
MemFree:          106528 kB
Buffers:           30116 kB
Cached:           123316 kB
SwapCached:            0 kB
Active:           164792 kB
Inactive:          85020 kB
Active(anon):      96692 kB
Inactive(anon):        0 kB
Active(file):      68100 kB
Inactive(file):    85020 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:         96412 kB
Mapped:            44536 kB
Shmem:               312 kB
Slab:               8940 kB
SReclaimable:       4848 kB
SUnreclaim:         4092 kB
KernelStack:        2528 kB
PageTables:         8324 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      191672 kB
Committed_AS:    6569284 kB
VmallocTotal:     614400 kB
VmallocUsed:       30656 kB
VmallocChunk:     520068 kB
.pre

^ Rooting

^^ nvflash

Press CTRL + ESC + power button to get into APX mode

.pre
[Thu Oct 11 06:31:57 2018] usb 2-2.4: new high-speed USB device number 13 using xhci_hcd
[Thu Oct 11 06:31:57 2018] usb 2-2.4: New USB device found, idVendor=0955, idProduct=7820, bcdDevice= 1.02
[Thu Oct 11 06:31:57 2018] usb 2-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Thu Oct 11 06:31:57 2018] usb 2-2.4: Product: APX
[Thu Oct 11 06:31:57 2018] usb 2-2.4: Manufacturer: NVIDIA Corp.
.pre

* http://tegradeveloper.nvidia.com/tegra-android-development-pack

In theory. In practice driver package from

* http://developer.download.nvidia.com/assets/mobile/files/tegra-linux-12.alpha.1.0.tar.gz

is everything you need. It's from http://developer.nvidia.com/content/linux-tegra-release-12-alpha-1-released

^^ fastboot.stock.bin

.pre
t61p:/home/dpavlin/Downloads/ldk/bootloader/alt# wget https://github.com/muromec/putusb/raw/master/bin/fastboot.stock.bin
--2011-09-12 20:40:17--  https://github.com/muromec/putusb/raw/master/bin/fastboot.stock.bin
Resolving github.com (github.com)... 207.97.227.239
Connecting to github.com (github.com)|207.97.227.239|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.github.com/muromec/putusb/master/bin/fastboot.stock.bin [following]
--2011-09-12 20:40:19--  https://raw.github.com/muromec/putusb/master/bin/fastboot.stock.bin
Resolving raw.github.com (raw.github.com)... 207.97.227.243
Connecting to raw.github.com (raw.github.com)|207.97.227.243|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 936016 (914K) [application/octet-stream]
Saving to: `fastboot.stock.bin'

100%[=====================================================>] 936,016      645K/s   in 1.4s    

2011-09-12 20:40:22 (645 KB/s) - `fastboot.stock.bin' saved [936016/936016]

t61p:/home/dpavlin/Downloads/ldk/bootloader/alt# md5sum fastboot.stock.bin 
9197365fb42c5801b4124e75ea00512c  fastboot.stock.bin
.pre

^^ backup

Following instructions at http://gitorious.org/ac100/pages/Installation

.pre
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash --bl fastboot.stock.bin --go
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 2
   chip sku: 0x8
   chip uid: 0x1700618943a00317
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: fastboot.stock.bin
| 936016/936016 bytes sent
fastboot.stock.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully


t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --getpartitiontable partitiontable.txt
Nvflash started
[resume mode]
Succesfully updated partition table information to partitiontable.txt


t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 2 part-2.img
Nvflash started
[resume mode]
receiving file: part-2.img, expected size: 3145728 bytes
/ 3145728/3145728 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 3 part-3.img
Nvflash started
[resume mode]
receiving file: part-3.img, expected size: 524288 bytes
/ 524288/524288 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# /nvflash -r --read 4 part-4.img
bash: /nvflash: No such file or directory
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 4 part-4.img
Nvflash started
[resume mode]
receiving file: part-4.img, expected size: 2097152 bytes
/ 2097152/2097152 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 5 part-5.img
Nvflash started
[resume mode]
receiving file: part-5.img, expected size: 5242880 bytes
/ 5242880/5242880 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 6 part-6.img
Nvflash started
[resume mode]
receiving file: part-6.img, expected size: 8388608 bytes
/ 8388608/8388608 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 7 part-7.img
Nvflash started
[resume mode]
receiving file: part-7.img, expected size: 1048576 bytes
/ 1048576/1048576 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 8 part-8.img
Nvflash started
[resume mode]
receiving file: part-8.img, expected size: 314572800 bytes
/ 314572800/314572800 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 9 part-9.img
Nvflash started
[resume mode]
receiving file: part-9.img, expected size: 419430400 bytes
/ 419430400/419430400 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 10 part-10.img
Nvflash started
[resume mode]
receiving file: part-10.img, expected size: 2097152 bytes
/ 2097152/2097152 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 11 part-11.img
Nvflash started
[resume mode]
receiving file: part-11.img, expected size: 524288 bytes
/ 524288/524288 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 12 part-12.img
Nvflash started
[resume mode]
receiving file: part-12.img, expected size: 1294991360 bytes
/ 1294991360/1294991360 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 13 part-13.img
Nvflash started
[resume mode]
receiving file: part-13.img, expected size: 524288 bytes
/ 524288/524288 bytes received
file received successfully
t61p:/home/dpavlin/Downloads/ldk/bootloader# ./nvflash -r --read 14 part-14.img
Nvflash started
[resume mode]
receiving file: part-14.img, expected size: 5891424256 bytes
/ 5891424256/5891424256 bytes received
file received successfully


.pre

^ Linux

^^ links

{fetchrss: http://feeds.delicious.com/v2/rss/dpavlin/ac100?count=15 full}

^^ phh 2.6.32 kernel with working suspend and audio

* http://salaliitto.com/~gildean/ac100/wiki/phh/

.pre
t61p:/home/dpavlin/ac100/linux4tegra_10.9.3# LD_LIBRARY_PATH=./nvflash/ ./nvflash/nvflash --bl ./prebuilt/fastboot.stock.bin --read 6 tegra_partition_6.bin --go
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 2
   chip sku: 0x8
   chip uid: 0x1700618943a00317
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: ./prebuilt/fastboot.stock.bin
| 936016/936016 bytes sent
./prebuilt/fastboot.stock.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
receiving file: tegra_partition_6.bin, expected size: 8388608 bytes
/ 8388608/8388608 bytes received
file received successfully



t61p:/home/dpavlin/ac100/linux4tegra_10.9.3# LD_LIBRARY_PATH=./nvflash/ ./nvflash/nvflash --wait --bl ./prebuilt/fastboot.stock.bin --download 6 ../32.boot.menu.v1.img --go
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 2
   chip sku: 0x8
   chip uid: 0x1700618943a00317
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: ./prebuilt/fastboot.stock.bin
| 936016/936016 bytes sent
./prebuilt/fastboot.stock.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
sending file: ../32.boot.menu.v1.img
/ 8388608/8388608 bytes sent
../32.boot.menu.v1.img sent successfully

.pre

^ mainline kernel

* Newest howto for arch: https://gist.github.com/Nokius/81cd46405b537931a472e0a55abb7ccd

* https://archlinuxarm.org/forum/viewtopic.php?f=49&t=10116

^ u-boot from APX

This should allow you to send u-boot, kernel and initramfs to any tegra2 board which can be in APX mode without
modifying internal storage.

^^ build u-boot

.pre
dpavlin@klin:/klin/u-boot$ cat env.sh 
export CROSS_COMPILE="arm-none-eabi-" ARCH=arm
dpavlin@klin:/klin/u-boot$ . env.sh 

dpavlin@klin:/klin/u-boot$ make paz00_defconfig

make


.pre

^^ build kernel

.pre
dpavlin@klin:/klin/Tegra/linux$ git remote -v
origin  https://github.com/grate-driver/linux (fetch)
origin  https://github.com/grate-driver/linux (push)
samsung-tab-10.1        https://github.com/Decatf/linux (fetch)
samsung-tab-10.1        https://github.com/Decatf/linux (push)

dpavlin@klin:/klin/Tegra/linux$ git branch -vv
* master 63a6317580f8 [origin/master] ARM: tegra: Clear EMC interrupts on resume from LP1 on Tegra30+

dpavlin@klin:/klin/Tegra/linux$ cat /klin/u-boot/env.sh 
export CROSS_COMPILE="arm-none-eabi-" ARCH=arm
dpavlin@klin:/klin/Tegra/linux$ . /klin/u-boot/env.sh

dpavlin@klin:/klin/Tegra/linux$ make tegra_defconfig

make


.pre

^^^ create initrd with new modules

.pre
dpavlin@klin:/klin/Tegra/linux$ cat tegra-ramdisk.sh 
#!/bin/sh -xe

test -d initrd && rm -Rf initrd

mkdir initrd
cd initrd

gzip -cd  /tmp/initrd.img | fakeroot -- cpio -i -d -H newc --no-absolute-filenames

rm -R lib/modules/*

cd ..
make modules_install INSTALL_MOD_PATH=initrd/ INSTALL_MOD_STRIP=1

cd initrd

find . | cpio -o -R 0:0 -H newc > ../initrd.new.cpio

cd ..

gzip -f -6 initrd.new.cpio

/klin/u-boot/tools/mkimage -A arm -O linux -T ramdisk -C gzip -n uInitrd -d initrd.new.cpio.gz uInitrd.new
.pre

run it to create initrd:

.pre
dpavlin@klin:/klin/Tegra/linux$ ./tegra-ramdisk.sh 

Image Name:   uInitrd
Created:      Fri Oct 12 11:20:42 2018
Image Type:   ARM Linux RAMDisk Image (gzip compressed)
Data Size:    4082917 Bytes = 3987.22 KiB = 3.89 MiB
Load Address: 00000000
Entry Point:  00000000

.pre

^^ create bootloader file

latest version seems to be: https://gitlab.com/uboot-ac100/create_bootimage.git

.pre
dpavlin@nuc:/nuc/Tegra/ac100/create_bootimage/example$ ../create_image.pl /mnt/klin/klin/u-boot/u-boot-dtb-tegra.bin /m
nt/klin/klin/Tegra/linux/arch/arm/boot/zImage /tmp/postmarketOS-export/initrd.img /mnt/klin/klin/Tegra/linux/arch/arm/b
oot/dts/tegra20-paz00.dtb uboot.scr boot.img
Creating boot image for tegrarcm ...

./tmp_uboot.scr
image layout:
section  loadaddr       size
=================================
uboot   : 0x108000      505627
kernel  : 0x190000      6485800
initrd  : 0x7c0000      4082981
fdt     : 0xbb0000      29659
script  : 0xbc0000      226

image written to boot.img
.pre

Now press CTRL + ESC + power on to enter APX mode

.pre
dpavlin@nuc:/nuc/Tegra/ac100/create_bootimage/example$ sudo apt-get install libcrypto++6

dpavlin@nuc:/nuc/Tegra/ac100/create_bootimage/example$ /mnt/klin/klin/Tegra/tegrarcm/src/tegrarcm --bct paz00-micron-toshiba-8g.bct --bootloader boot.img --loadaddr 0x108000 
bct file: paz00-micron-toshiba-8g.bct
bootloader file: boot.img
load addr 0x108000
entry addr 0x108000
device id: 0x7820
uid:  0x1700618943a00317
RCM version: 2.1
downloading miniloader to target at address 0x40008000 (132976 bytes)...
miniloader downloaded successfully
Chip UID:                0x00000000000000001700618943a00317
Chip ID:                 0x20
Chip ID Major Version:   0x1
Chip ID Minor Version:   0x2
Chip SKU:                0x8 (t20)
Boot ROM Version:        0x1
Boot Device:             0x2 (EMMC)
Operating Mode:          0x3 (developer mode)
Device Config Strap:     0x0
Device Config Fuse:      0x0
SDRAM Config Strap:      0x0
sending file: paz00-micron-toshiba-8g.bct
- 4080/4080 bytes sent
paz00-micron-toshiba-8g.bct sent successfully
sending file: boot.img
- 11239650/11239650 bytes sent
boot.img sent successfully

.pre

u-boot loads detects initrd (it's small enough thanks to MODULES_STRIP to be detected without CRC errors) but no output from kernel.

https://archlinuxarm.org/forum/viewtopic.php?f=23&t=10044&p=51142&hilit=ac100#p51142

suggests CONFIG_TEGRA_DEBUG_UARTA instead of CONFIG_TEGRA_DEBUG_UART_AUTO_ODMDATA but it doesn't work for me.

.pre
dpavlin@klin:/klin/Tegra/linux$ grep 'TEGRA.*UART' .config
# CONFIG_TEGRA_DEBUG_UART_AUTO_ODMDATA is not set
CONFIG_TEGRA_DEBUG_UARTA=y
# CONFIG_TEGRA_DEBUG_UARTB is not set
# CONFIG_TEGRA_DEBUG_UARTC is not set
# CONFIG_TEGRA_DEBUG_UARTD is not set
# CONFIG_TEGRA_DEBUG_UARTE is not set
CONFIG_DEBUG_TEGRA_UART=y


.pre

^ serial port

https://ac100.grandou.net/serial_port_modification

{image: IMG_20181014_181159-800px.jpg}

The serial port is the JP1 connector, near the left speaker connector. Pinout, from right to left:

* 1 - in - RX UART1
* 2 - out - TX UART1
* 3 - out - T20_WAKE#
* 4 - out - +3V
* 5 - out - +1.8V
* 6
* 7
* 8 - in - SYSTEM_RESET#
* 9 - in - EC_TX80_PDATA
* 10 - in - GND

I decided to solder GND to outer pin of connector to the right of pin 1 as opposed to other side of connector.

After that, a peace of capton tape was put over solder connectors to somewhat re-enforce them and provide insulation
to keyboard cover.

Serial is 3.3V, 115200 8n1.

Output is:

.pre
dpavlin@nuc:/nuc/Tegra$ microcom -p /dev/ttyUSB2
connected to /dev/ttyUSB2
Escape character: Ctrl-\
Type the escape character to get to the prompt.

U-Boot SPL 2018.11-rc1-00130-g0a60a81ba3 (Oct 12 2018 - 11:18:01 +0200)
Trying to boot from RAM


U-Boot 2018.11-rc1-00130-g0a60a81ba3 (Oct 12 2018 - 11:18:01 +0200)

TEGRA20
Model: Toshiba AC100 / Dynabook AZ
Board: Compal Paz00
DRAM:  512 MiB
MMC:   sdhci@c8000000: 1, sdhci@c8000600: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   No ethernet found.
Hit any key to stop autoboot:  0
## Executing script at 00b30000
## Loading init Ramdisk from Legacy Image at 00700000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    4269789 Bytes = 4.1 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 00b20000
   Booting using the fdt blob at 0xb20000
   Using Device Tree in place at 00b20000, end 00b2a3da

Starting kernel ...


Error: invalid dtb and unrecognized/unsupported machine ID
  r1=0x00000c38, r2=0x00000000
Available machine support:

ID (hex)        NAME
ffffffff        Generic DT based system
ffffffff        NVIDIA Tegra SoC (Flattened Device Tree)

Please check your kernel config and/or bootloader.

.pre

According to http://billauer.co.il/blog/2014/02/uboot-linux-dtb-fdt-device-tree/ this means that kernel didn't found valid device tree and tries to detect board usin machine ID registrars.

Solution for this seems to use u-boot variables for loading kernel, ramfs and dtb as opposed to values which script creates,
so this works (loading from usb keychain):

.pre
fatload usb 0:1 ${kernel_addr_r} /boot/zImage
fatload usb 0:1 ${fdt_addr_r} /boot/tegra20-paz00.dtb
fatload usb 0:1 ${ramdisk_addr_r} /boot/uInitrd.new
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
.pre

Here are also known working addresses which u-boot uses:

.pre
Tegra20 (Paz00) MOD # echo ${kernel_addr_r}
0x01000000
Tegra20 (Paz00) MOD # echo ${fdt_addr_r}
0x02000000
Tegra20 (Paz00) MOD # echo ${ramdisk_addr_r} 
0x02100000
.pre

so much higher in memory map than create_image script. However, u-boot seems to want to load at 0x108000 so it's inpractical
to generate huge image to load kernel, dtb and initramfs at correct addresses.

^ bootstrap debian

based on https://wiki.debian.org/InstallingDebianOn/Toshiba/AC100

.pre
dpavlin@nuc:/mnt$ sudo debootstrap --foreign --arch=armhf stretch sdd1 http://ftp.hr.debian.org/debian

dpavlin@nuc:/mnt$ df sdd1/
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/sdd1        1021948 169056    784596  18% /mnt/sdd1

dpavlin@nuc:/mnt$ sudo cp /usr/bin/qemu-arm-static sdd1/usr/bin

dpavlin@nuc:/mnt$ sudo chroot sdd1 /debootstrap/debootstrap --second-stage

dpavlin@nuc:/mnt$ cd sdd1/
dpavlin@nuc:/mnt/sdd1$ sudo mount --bind /sys sys
dpavlin@nuc:/mnt/sdd1$ sudo mount --bind /dev dev
dpavlin@nuc:/mnt/sdd1$ sudo mount --bind /proc proc
dpavlin@nuc:/mnt/sdd1$ sudo chroot .

root@nuc:/# apt-get install u-boot-tools

root@ac100:/boot# cat boot.cmd 
ext2load usb 0:1 ${kernel_addr_r} /boot/zImage
ext2load usb 0:1 ${fdt_addr_r} /boot/tegra20-paz00.dtb
ext2load usb 0:1 ${ramdisk_addr_r} /boot/uInitrd
setenv bootargs root=/dev/sda1 rootwait CMA=64M tegrapart=recovery:300:a00:800,boot:d00:1000:800,mbr:1d00:200:800
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr





.pre

^ u-boot over pax, usb filesystem

.pre
dpavlin@nuc:/nuc/Tegra/ac100/create_bootimage/example$ /mnt/klin/klin/Tegra/tegrarcm/src/tegrarcm --bct paz00-micron-toshiba-8g.bct --bootloader /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-dtb-tegra.bin --loadaddr 0x108000
bct file: paz00-micron-toshiba-8g.bct

.pre

Serial output:

.pre
U-Boot SPL 2018.09-rc2-38340-g3d186cf3f3 (Oct 20 2018 - 10:46:53 +0200)
Trying to boot from RAM


U-Boot 2018.09-rc2-38340-g3d186cf3f3 (Oct 20 2018 - 10:46:53 +0200)

TEGRA20
Model: Toshiba AC100 / Dynabook AZ
Board: Compal Paz00
DRAM:  512 MiB
MMC:   sdhci@c8000000: 1, sdhci@c8000600: 0
Loading Environment from MMC... OK
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   No ethernet found.
starting USB...
USB0:   USB EHCI 1.00
USB1:   No code to set up ULPI controller, please enableCONFIG_USB_ULPI and CONFIG_USB_ULPI_VIEWPORTprobe failed, error -38
USB2:   USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0
Tegra20 (Paz00) MOD # run usb_boot

.pre

^ wifi

.pre
root@ac100:/etc/network/interfaces.d# apt-get install firmware-ralink wpasupplicant

root@ac100:/etc/network/interfaces.d# cat wlx6c626d1788b3 
allow-hotplug wlx6c626d1788b3
iface wlx6c626d1788b3 inet dhcp
        wpa-ssid dreamhouse
        wpa-psk xxxxxxxx

.pre

^ disk speed

.pre
root@ac100:~# hdparm -tT /dev/sda /dev/mmcblk1

/dev/sda:
 Timing cached reads:   560 MB in  2.01 seconds = 279.14 MB/sec
 Timing buffered disk reads:  32 MB in  3.07 seconds =  10.43 MB/sec

/dev/mmcblk1:
 Timing cached reads:   598 MB in  2.00 seconds = 298.86 MB/sec
 Timing buffered disk reads: 108 MB in  3.01 seconds =  35.83 MB/sec
.pre

^^ tuhing block size

.pre
root@ac100:/home/dpavlin/flashbench# ./flashbench -a /dev/mmcblk1 --blocksize=1024
align 2147483648        pre 727µs      on 1.07ms       post 784µs     diff 316µs
align 1073741824        pre 833µs      on 1.13ms       post 789µs     diff 320µs
align 536870912 pre 798µs      on 1.13ms       post 825µs     diff 317µs
align 268435456 pre 816µs      on 1.15ms       post 795µs     diff 342µs
align 134217728 pre 742µs      on 1.12ms       post 843µs     diff 327µs
align 67108864  pre 669µs      on 987µs       post 701µs     diff 303µs
align 33554432  pre 662µs      on 1.04ms       post 643µs     diff 385µs
align 16777216  pre 837µs      on 1.09ms       post 864µs     diff 242µs
align 8388608   pre 800µs      on 1.1ms        post 881µs     diff 262µs
align 4194304   pre 812µs      on 1.07ms       post 838µs     diff 246µs
align 2097152   pre 807µs      on 1.07ms       post 808µs     diff 258µs
align 1048576   pre 832µs      on 960µs       post 838µs     diff 125µs
align 524288    pre 833µs      on 959µs       post 838µs     diff 124µs
align 262144    pre 833µs      on 959µs       post 838µs     diff 124µs
align 131072    pre 833µs      on 962µs       post 840µs     diff 126µs
align 65536     pre 825µs      on 951µs       post 838µs     diff 120µs
align 32768     pre 826µs      on 956µs       post 825µs     diff 130µs
align 16384     pre 812µs      on 924µs       post 824µs     diff 106µs
align 8192      pre 809µs      on 841µs       post 808µs     diff 32.4µs
align 4096      pre 808µs      on 836µs       post 808µs     diff 27.7µs
align 2048      pre 808µs      on 836µs       post 809µs     diff 27.6µs
.pre

8192 seems good, re-test

.pre
root@ac100:/home/dpavlin/flashbench# ./flashbench -a /dev/mmcblk1 --blocksize=4096
align 2147483648        pre 696µs      on 1.04ms       post 725µs     diff 331µs
align 1073741824        pre 917µs      on 1.18ms       post 870µs     diff 289µs
align 536870912 pre 880µs      on 1.18ms       post 907µs     diff 291µs
align 268435456 pre 899µs      on 1.2ms        post 877µs     diff 311µs
align 134217728 pre 825µs      on 1.18ms       post 927µs     diff 300µs
align 67108864  pre 864µs      on 1.11ms       post 842µs     diff 253µs
align 33554432  pre 914µs      on 1.12ms       post 897µs     diff 212µs
align 16777216  pre 921µs      on 1.14ms       post 948µs     diff 210µs
align 8388608   pre 884µs      on 1.15ms       post 965µs     diff 229µs
align 4194304   pre 895µs      on 1.12ms       post 922µs     diff 215µs
align 2097152   pre 890µs      on 1.12ms       post 890µs     diff 227µs
align 1048576   pre 916µs      on 1.01ms       post 922µs     diff 89.7µs
align 524288    pre 916µs      on 1.01ms       post 922µs     diff 90µs
align 262144    pre 916µs      on 1.01ms       post 923µs     diff 89.1µs
align 131072    pre 916µs      on 1.01ms       post 924µs     diff 91.1µs
align 65536     pre 908µs      on 1ms  post 921µs     diff 85.9µs
align 32768     pre 911µs      on 1.01ms       post 908µs     diff 96.2µs
align 16384     pre 895µs      on 973µs       post 908µs     diff 71.4µs
align 8192      pre 892µs      on 896µs       post 892µs     diff 4.57µs
.pre

create filesystem

.pre
root@ac100:/home/dpavlin/flashbench# mkfs -t ext4 -v -b 4096 -E stride=2,stripe-width=2 /dev/mmcblk1p6 

cp -ax ....

root@ac100:~# mount /dev/mmcblk1p1 /tmp/1/
root@ac100:~# cat /tmp/1/boot/boot.cmd 
ext2load mmc 0:6 ${kernel_addr_r} /boot/zImage
ext2load mmc 0:6 ${fdt_addr_r} /boot/tegra20-paz00.dtb
ext2load mmc 0:6 ${ramdisk_addr_r} /boot/uInitrd
setenv bootargs root=/dev/mmcblk1p6 rootwait CMA=64M tegrapart=recovery:300:a00:800,boot:d00:1000:800,mbr:1d00:200:800
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# mkimage -C none -A arm -T script -d boot.cmd boot.scr


.pre

^ flash u-boot to mmc

based on https://paz00.ru/index.php?title=Flashing_Uboot_to_MMC&setlang=en

^^ tegrarcm to get bct

.pre
dpavlin@nuc:/nuc/Tegra$ git clone https://github.com/NVIDIA/tegrarcm

dpavlin@nuc:/nuc/Tegra$ cd tegrarcm/

dpavlin@nuc:/nuc/Tegra/tegrarcm$ sudo apt-get install libcrypto++-dev

dpavlin@nuc:/nuc/Tegra/tegrarcm$ ./autogen.sh

dpavlin@nuc:/nuc/Tegra/tegrarcm$ make

dpavlin@nuc:/nuc/Tegra/tegrarcm$ ./src/tegrarcm --version
tegrarcm 1.8
.pre

^^ create boot image

.pre
dpavlin@nuc:/nuc/Tegra/cbootimage$ git remote -v
origin  https://github.com/NVIDIA/cbootimage (fetch)
origin  https://github.com/NVIDIA/cbootimage (push)

dpavlin@nuc:/nuc/Tegra/cbootimage$ ./autogen.sh
dpavlin@nuc:/nuc/Tegra/cbootimage$ make


dpavlin@nuc:/nuc/Tegra/cbootimage$ cat > u-boot.cfg
Version       = 0x00020001;
Bctcopy       = 1;
Bctfile       = ac100.bct;
BootLoader    = u-boot.bin,0x00108000,0x00108000,Complete;


dpavlin@nuc:/nuc/Tegra/cbootimage$ cp ../ac100/create_bootimage/example/ac100-dpavlin.bct ac100.bct

dpavlin@nuc:/nuc/Tegra/cbootimage$ cp /mnt/klin/klin/Tegra/u-boot-tegra/u-boot-tegra.bin u-boot.bin

dpavlin@nuc:/nuc/Tegra/cbootimage$ ./src/cbootimage -d u-boot.cfg ac100.bct.new
bct size: 4080
**update_bl()
begin_update(): bct data: b=14 p=9
writing bootloader
  redundancy = 1
  BL[0]: 131073 0001 0000 518563 0x00108000 0x00108000
8e52c9639cb433e9e1e369cf718595c5
  BL[1]: 131073 0002 0000 302746 0x00108000 0x00108000
a9014f31e7ccafab319512de6bc48f81
**BL[2]: 0 0000 0000 0000 0x00000000 0x00000000
00000000000000000000000000000000
**BL[3]: 0 0000 0000 0000 0x00000000 0x00000000
00000000000000000000000000000000
Image file ac100.bct.new has been successfully generated!

dpavlin@nuc:/nuc/Tegra/cbootimage$ scp ac100.bct.new ac100:

dpavlin@nuc:/nuc/Tegra/cbootimage$ ssh root@ac100

# flash new boot image on ac100

root@ac100:~# echo 0 > /sys/block/mmcblk1boot0/force_ro
root@ac100:~# dd if=/home/dpavlin/ac100.bct.new of=/dev/mmcblk1boot0 
1045+0 records in
1045+0 records out
535040 bytes (535 kB, 522 KiB) copied, 0.135589 s, 3.9 MB/s
root@ac100:~# echo 1 > /sys/block/mmcblk1boot0/force_ro 



.pre

create bct backup

.pre
dpavlin@ac100:~$ sudo dd if=/dev/mmcblk1boot0 of=ac100-dpavlin-0.bct bs=4080 count=1
[sudo] password for dpavlin: 
1+0 records in
1+0 records out
4080 bytes (4.1 kB, 4.0 KiB) copied, 0.0018642 s, 2.2 MB/s
dpavlin@ac100:~$ sudo dd if=/dev/mmcblk1boot1 of=ac100-dpavlin-1.bct bs=4080 count=1
1+0 records in
1+0 records out
4080 bytes (4.1 kB, 4.0 KiB) copied, 0.0019622 s, 2.1 MB/s
.pre

in my case, first bct doesn't have OdmData, while 2nd does:

.pre
dpavlin@nuc:/nuc/Tegra$ grep Odm 0 1
0:OdmData       = 0x00000000;
1:OdmData       = 0x800c0075;


.pre

^ i2c

.pre
root@ac100:~# i2cdetect -y -r 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 4f 
50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@ac100:~# i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@ac100:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
.pre
^ open source toolchain

* https://github.com/SymbiFlow/prjtrellis

.pre
dpavlin@klin:/klin/FPGA$ git clone https://github.com/SymbiFlow/prjtrellis
dpavlin@klin:/klin/FPGA/prjtrellis$ ./download-latest-db.sh 

dpavlin@klin:/klin/FPGA/prjtrellis$ cd libtrellis/
dpavlin@klin:/klin/FPGA/prjtrellis/libtrellis$ sudo apt-get install libpython3-dev libboost-python-dev libboost-filesystem-dev libboost-thread-dev libboost-program-options-dev
dpavlin@klin:/klin/FPGA/prjtrellis/libtrellis$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local .
dpavlin@klin:/klin/FPGA/prjtrellis/libtrellis$ make






.pre
^ open source support

* https://robertou.com/unofficial-open-source-place-and-route-for-xilinx-coolrunner-ii-cplds.html

.pre
dpavlin@klin:/klin/FPGA$ sudo apt-get install cargo

dpavlin@klin:/klin/FPGA$ git clone https://github.com/azonenberg/openfpga

dpavlin@klin:/klin/FPGA$ cd openfpga/src/xc2par/

dpavlin@klin:/klin/FPGA/openfpga/src/xc2par$ cargo build --release


dpavlin@klin:/klin/FPGA/openfpga/src/xc2par$ cargo install --root /usr/local
warning: Using `cargo install` to install the binaries for the project in current working directory is deprecated, use `cargo install --path .` instead. Use `cargo build` if you want to simply build the package.
  Installing xc2par v0.0.2 (/klin/FPGA/openfpga/src/xc2par)
    Finished release [optimized] target(s) in 0.07s                                            
  Installing /usr/local/bin/yosys-json-to-intermed-json
  Installing /usr/local/bin/inputgraph-json-par
  Installing /usr/local/bin/intermed-json-to-inputgraph-json
  Installing /usr/local/bin/demo-driver
  Installing /usr/local/bin/xc2par

dpavlin@klin:/klin/FPGA$ yosys -p "synth_coolrunner2 -json blinky.json" blinky.v
dpavlin@klin:/klin/FPGA$ xc2par -p xc2c32a-4-vq44 blinky.json
dpavlin@klin:/klin/FPGA$ ls -al blinky.jed 
-rw-r--r-- 1 dpavlin dpavlin 15870 Nov  5 14:33 blinky.jed


dpavlin@klin:/klin/FPGA$ git clone https://github.com/azonenberg/jtaghal-cmake
dpavlin@klin:/klin/FPGA$ cd jtaghal-cmake/
dpavlin@klin:/klin/FPGA/jtaghal-cmake$ git submodule init
dpavlin@klin:/klin/FPGA/jtaghal-cmake$ git submodule update
dpavlin@klin:/klin/FPGA/jtaghal-cmake$ mkdir build
dpavlin@klin:/klin/FPGA/jtaghal-cmake$ cd build/
dpavlin@klin:/klin/FPGA/jtaghal-cmake/build$ sudo apt-get install libprotobuf-dev protobuf-compiler libedit-dev
dpavlin@klin:/klin/FPGA/jtaghal-cmake/build$ cmake ..
dpavlin@klin:/klin/FPGA/jtaghal-cmake/build$ make



.pre

^ boards

I have two CoolRunner-II boards from Dangerous Prototypes:

^^ XC2C32A Bus Blaster

* http://dangerousprototypes.com/docs/Bus_Blaster
* v2.0a1 and v.2.5 - http://dangerousprototypes.com/docs/Bus_Blaster_v2_design_overview

* https://github.com/DangerousPrototypes/Bus_Blaster/tree/master/hardware

^^ XC95144XL breakout board

* http://dangerousprototypes.com/blog/2011/11/24/xc95144xl-breakout-board/
* http://dangerousprototypes.com/docs/Ricet_:_XC95144_CPLD_Breakout_Board_development
* https://github.com/scanlime/dangerous-prototypes-open-hardware/tree/master/CPLD_Breakout/hardware/Xilinx
[ESP8266] based H801 LED Wifi Controller

* https://github.com/arendst/Sonoff-Tasmota/wiki/H801

* https://github.com/arendst/Sonoff-Tasmota/wiki/Esptool

.pre
dpavlin@nuc:/nuc/esptool$ wget https://github.com/arendst/Sonoff-Tasmota/releases/download/v6.2.1/sonoff-sensors.bin

pi@rpi2 /nuc/esptool $ ./esptool.py --port /dev/ttyUSB2 write_flash -fs 1MB -fm dout 0x0 ./sonoff-sensors.bin 
esptool.py v2.3-dev
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 506336 bytes to 345467...
Wrote 506336 bytes (345467 compressed) at 0x00000000 in 31.6 seconds (effective 128.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
.pre

Now turn off board, remove jumper and blindly type in terminal

.pre
module 20
.pre

This didn't work for me, so I opened new wifi network on Android phone and configured wifi there.
{image: ch340g-3v3.png}

{image: ch340g-5v.png}

Some of those serial dongles (I have one which is intended for esp01) have been configured for 5V operation instead of 3.3V.

You can check that by measuring RX and TX while plugged in in USB and if they are more than 3.3V your dongle is not really
3.3V.
{toc: }

* http://www.gotroot.ca/rigol/

^ LAN

* https://github.com/RoGeorge/DS1054Z_screen_capture

.pre
dpavlin@x200:/rest/cvs$ git clone https://github.com/RoGeorge/DS1054Z_screen_capture
Cloning into 'DS1054Z_screen_capture'...
remote: Counting objects: 77, done.
remote: Total 77 (delta 0), reused 0 (delta 0), pack-reused 77
Unpacking objects: 100% (77/77), done.
Checking connectivity... done.
dpavlin@x200:/rest/cvs$ cd DS1054Z_screen_capture/
dpavlin@x200:/rest/cvs/DS1054Z_screen_capture$ 

dpavlin@x200:/rest/cvs/DS1054Z_screen_capture$ python OscScreenGrabLAN.py png 192.168.3.250
Instrument ID: RIGOL TECHNOLOGIES,DS1104Z,DS1ZA172114616,00.04.03.SP2

Receiving screen capture...
Saved file: DS1104Z_DS1ZA172114616_2015-12-31_14.11.17.png
.pre

* https://github.com/pklaus/ds1054z

.pre
dpavlin@x200:/rest/cvs$ git clone https://github.com/pklaus/ds1054z
Cloning into 'ds1054z'...
remote: Counting objects: 693, done.
remote: Total 693 (delta 0), reused 0 (delta 0), pack-reused 693
Receiving objects: 100% (693/693), 136.88 KiB | 0 bytes/s, done.
Resolving deltas: 100% (340/340), done.
Checking connectivity... done.
dpavlin@x200:/rest/cvs$ cd ds1054z/
dpavlin@x200:/rest/cvs/ds1054z$ sudo python setup.py install
dpavlin@x200:/rest/cvs/ds1054z$ sudo apt-get install python-zeroconf

dpavlin@x200:/rest/cvs/ds1054z$ ds1054z discover
192.168.3.250

dpavlin@x200:/rest/cvs/ds1054z$ ds1054z info

Vendor:   RIGOL TECHNOLOGIES
Product:  DS1104Z
Serial:   DS1ZA172114___
Firmware: 00.04.03.SP2

dpavlin@x200:/rest/cvs/ds1054z$ ds1054z save-screen
ds1054z-scope-display_2015-12-31_14-19-52.png
.pre

* https://github.com/Teuniz/DSRemote.git

^ VISA

* https://github.com/rheslip/PyDSA

^ USB

* https://github.com/wd5gnr/qrigol

^ firmware update

* http://beyondmeasure.rigoltech.com/acton/fs/blocks/showLandingPage/a/1579/p/p-0019/t/page/fm/0

.pre
dpavlin@x200:/tmp$ unzip -t DS1000Z\(ARM\)Update_00.04.03.02.03.zip 
Archive:  DS1000Z(ARM)Update_00.04.03.02.03.zip
    testing: DS1000Z(ARM)Update_00.04.03.02.03/   OK
    testing: DS1000Z(ARM)Update_00.04.03.02.03/DS1000ZUpdate.GEL   OK
No errors detected in compressed data of DS1000Z(ARM)Update_00.04.03.02.03.zip.
.pre

^ hints

* Menu, Menu, Force, Menu - access system info menu

^ plugins for firmware

https://www.eevblog.com/forum/testgear/rigol-ds1000z-firmware-patch-plugins/
Schematics and service manual for i9250: {file: Samsung_i9250_schem_sm.rar}

{toc: }

.pre
127|root@maguro:/ # cat /proc/cpuinfo                                          
Processor       : ARMv7 Processor rev 10 (v7l)
processor       : 0
BogoMIPS        : 1194.24

processor       : 1
BogoMIPS        : 1194.24

Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc09
CPU revision    : 10

Hardware        : Tuna
Revision        : 0009
Serial          : 014994b30201c013
.pre

^ BLE

* https://github.com/metc/galaxy-nexus-ble

^ GSM modem over serial port

* https://github.com/2b-as/xgoldmon

^ HID keyboard

* https://github.com/pelya/android-keyboard-gadget

^ Unlegacy Android

ASOP for OMAP4 devices:

https://forum.xda-developers.com/galaxy-nexus/development/rom-omap4-aosp-project-t3334574

https://github.com/Unlegacy-Android/

^^ kernel

http://unlegacy-android.cf/

https://github.com/Unlegacy-Android/android_kernel_samsung_tuna

.pre
dpavlin@klin:/virtual/android/galaxy-nexus$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/

dpavlin@klin:/virtual/android/galaxy-nexus/omap$ git checkout -b asop-7.1 unlegacy/aosp-7.1

dpavlin@klin:/virtual/android/galaxy-nexus/omap$ make tuna_defconfig ARCH=arm

dpavlin@klin:/virtual/android/galaxy-nexus/omap$ cp include/linux/compiler-gcc4.h include/linux/compiler-gcc5.h


dpavlin@klin:/virtual/android/galaxy-nexus/omap$ make -j9 ARCH=arm CROSS_COMPILE=arm-none-eabi-
.pre

^ OMAP4 USB boot

Somewhat interesting things that I can take a look at some time in the future:

* https://github.com/swetland/omap4boot
** newer(ish) version is on https://github.com/dmitry-pervushin/usbboot-omap4

To compile it needs following change:

.pre
dpavlin@nuc:/nuc/Galaxy-Nexus-i9250/usbboot-omap4$ git diff
diff --git a/Makefile b/Makefile
index 2d10c73..9ea9461 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ BINDIR ?= $(DESTDIR)/usr/bin
 DATADIR ?= $(DESTDIR)/usr/share/usbboot
 DOCDIR ?= $(DESTDIR)/usr/share/doc/usbboot
 
-BOARD ?= panda
+BOARD ?= tuna
 
 TARGET_CC := $(TOOLCHAIN)gcc
 TARGET_LD := $(TOOLCHAIN)ld
diff --git a/tools/usb-linux.c b/tools/usb-linux.c
index e3492a1..09c40de 100755
--- a/tools/usb-linux.c
+++ b/tools/usb-linux.c
@@ -10,7 +10,7 @@ int linux_usb_init(void)
        r = libusb_init(&ctx);
        if (r != 0)
                return r;
-       libusb_set_debug(ctx,0x1);
+       //libusb_set_debug(ctx,0x1);
     return 0;
 }
.pre

^ Odin

* http://glassechidna.com.au/heimdall/

^ serial

* https://wiki.postmarketos.org/wiki/Serial_debugging#USB_debug_cable

{image: Nexus-usb-debug.png}

| Device | Codename | Resistor (R3) | Connected VCC |
| Google Galaxy Nexus (GSM) | samsung-maguro | 619K ohm | No |
| Samsung Galaxy Mini 2 | samsung-s6500d | 530K ohm | No |
| Samsung Galaxy S4 Mini LTE | samsung-i9195 | 619K ohm | No |
| Samsung Galaxy S5 | samsung-klte | 619K ohm | No |

It seems that other suggestion is 150k from https://redmine.replicant.us/projects/replicant/wiki/SamsungSerial - I will have to test which value works

^ UART modes

* https://wiki.postmarketos.org/wiki/Micro-USB_Interface_Controller

| Resistance | Jig | Boot |
| 150k | Inactive | Inactive |
| 523k | Active | Inactive |
| 619k | Active | Active |

.pre
RID_USB_OTG_MODE,	/* 0 0 0 0 0 	GND 		USB OTG Mode              */
RID_AUD_SEND_END_BTN,	/* 0 0 0 0 1 	2K		Audio Send_End Button*/
RID_AUD_REMOTE_S1_BTN,	/* 0 0 0 1 0 	2.604K		Audio Remote S1 Button */
RID_AUD_REMOTE_S2_BTN,	/* 0 0 0 1 1 	3.208K		Audio Remote S2 Button                         */
RID_AUD_REMOTE_S3_BTN,	/* 0 0 1 0 0 	4.014K		Audio Remote S3 Button */
RID_AUD_REMOTE_S4_BTN,	/* 0 0 1 0 1 	4.82K		Audio Remote S4 Button */
RID_AUD_REMOTE_S5_BTN,	/* 0 0 1 1 0 	6.03K		Audio Remote S5 Button */
RID_AUD_REMOTE_S6_BTN,	/* 0 0 1 1 1 	8.03K		Audio Remote S6 Button */
RID_AUD_REMOTE_S7_BTN,	/* 0 1 0 0 0 	10.03K		Audio Remote S7 Button */
RID_AUD_REMOTE_S8_BTN,	/* 0 1 0 0 1 	12.03K		Audio Remote S8 Button */
RID_AUD_REMOTE_S9_BTN,	/* 0 1 0 1 0 	14.46K		Audio Remote S9 Button */
RID_AUD_REMOTE_S10_BTN,	/* 0 1 0 1 1 	17.26K		Audio Remote S10 Button */
RID_AUD_REMOTE_S11_BTN,	/* 0 1 1 0 0 	20.5K		Audio Remote S11 Button */
RID_AUD_REMOTE_S12_BTN,	/* 0 1 1 0 1 	24.07K		Audio Remote S12 Button */
RID_RESERVED_1,		/* 0 1 1 1 0 	28.7K		Reserved Accessory #1 */
RID_RESERVED_2,		/* 0 1 1 1 1 	34K 		Reserved Accessory #2 */
RID_RESERVED_3,		/* 1 0 0 0 0 	40.2K		Reserved Accessory #3 */
RID_RESERVED_4,		/* 1 0 0 0 1 	49.9K		Reserved Accessory #4 */
RID_RESERVED_5,		/* 1 0 0 1 0 	64.9K		Reserved Accessory #5 */
RID_AUD_DEV_TY_2,	/* 1 0 0 1 1 	80.07K		Audio Device Type 2 */
RID_PHONE_PWD_DEV,	/* 1 0 1 0 0 	102K		Phone Powered Device */
RID_TTY_CONVERTER,	/* 1 0 1 0 1 	121K		TTY Converter */
RID_UART_CABLE,		/* 1 0 1 1 0 	150K		UART Cable */
RID_CEA936A_TY_1,	/* 1 0 1 1 1 	200K		CEA936A Type-1 Charger(1) */
RID_FM_BOOT_OFF_USB,	/* 1 1 0 0 0 	255K		Factory Mode Boot OFF-USB */
RID_FM_BOOT_ON_USB,	/* 1 1 0 0 1 	301K		Factory Mode Boot ON-USB */
RID_AUD_VDO_CABLE,	/* 1 1 0 1 0 	365K		Audio/Video Cable */
RID_CEA936A_TY_2,	/* 1 1 0 1 1 	442K		CEA936A Type-2 Charger(1) */
RID_FM_BOOT_OFF_UART,	/* 1 1 1 0 0 	523K		Factory Mode Boot OFF-UART */
RID_FM_BOOT_ON_UART,	/* 1 1 1 0 1 	619K		Factory Mode Boot ON-UART */
RID_AUD_DEV_TY_1_REMOTE, /* 1 1 1 1 0 	1000.07K	Audio Device Type 1 with Remote(1) */
RID_AUD_DEV_TY_1_SEND = RID_AUD_DEV_TY_1_REMOTE , /* 1 1 1 1 0 	1002K		Audio Device Type 1 / Only Send-End(2) */
RID_USB_MODE,		/* 1 1 1 1 1 	Open		USB Mode, Dedicated Charger or Accessory Detach */
.pre

{image: usbid_allresistorvalues.png}

^ PostmarketOS

.pre
dpavlin@nuc:/nuc/pmbootstrap$ ./pmbootstrap.py install --no-fde
[17:54:17] *** (1/5) PREPARE NATIVE CHROOT ***
[17:54:18] *** (2/5) CREATE DEVICE ROOTFS ("samsung-maguro") ***
[17:54:23] (rootfs_samsung-maguro) install
[17:54:27] (rootfs_samsung-maguro) install
[17:54:30] (rootfs_samsung-maguro) write /etc/os-release
[17:54:30] (rootfs_samsung-maguro) mkinitfs samsung-maguro
[17:54:34]  *** SET LOGIN PASSWORD FOR: 'dpavlin' ***
New password:
Retype new password:
passwd: password updated successfully
[17:54:43] NOTE: No valid keymap specified for device
[17:54:46] *** (3/5) PREPARE INSTALL BLOCKDEVICE ***
[17:54:47] (native) create samsung-maguro.img (361M)
[17:54:47] (native) mount /dev/install (samsung-maguro.img)
[17:54:47] (native) partition /dev/install (boot: 31M, root: the rest)
[17:54:47] (native) format /dev/installp2
[17:54:48] (native) mount /dev/installp2 to /mnt/install
[Tue Sep 25 17:55:21 2018] EXT4-fs (loop0p2): mounted filesystem with ordered data mode. Opts: (null)
[17:54:48] (native) format /dev/installp1 (boot, ext2), mount to /mnt/install/boot
[Tue Sep 25 17:55:21 2018] EXT4-fs (loop0p1): mounting ext2 file system using the ext4 subsystem
[Tue Sep 25 17:55:21 2018] EXT4-fs (loop0p1): mounted filesystem without journal. Opts: (null)
[17:54:48] *** (4/5) FILL INSTALL BLOCKDEVICE ***
[17:54:48] (native) copy rootfs_samsung-maguro to /mnt/install/
[17:54:53] *** (5/5) FLASHING TO DEVICE ***
[17:54:53] Run the following to flash your installation to the target device:
[17:54:53] * pmbootstrap flasher flash_rootfs
[17:54:53]   Flashes the generated rootfs image to your device:
[17:54:53]   /nuc/pmbootstrap-work/chroot_native/home/pmos/rootfs/samsung-maguro.img
[17:54:53]   (NOTE: This file has a partition table, which contains /boot and / subpartitions. That way we don't need to change the partition layout on your device.)
[17:54:53] * pmbootstrap flasher flash_kernel
[17:54:53]   Flashes the kernel + initramfs to your device:
[17:54:53]   /nuc/pmbootstrap-work/chroot_rootfs_samsung-maguro/boot
[17:54:53]   (NOTE: fastboot also supports booting the kernel/initramfs directly without flashing. Use 'pmbootstrap flasher boot' to do that.)
[17:54:53] * If the above steps do not work, you can also create symlinks to the generated files with 'pmbootstrap export' and flash outside of pmbootstrap.
[17:54:53] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[17:54:53] Done

dpavlin@nuc:/nuc/pmbootstrap$ alias pmbootstrap=/nuc/pmbootstrap/pmbootstrap.py
dpavlin@nuc:/nuc/pmbootstrap$ pmbootstrap flasher flash_rootfs
[17:57:10] (native) flash rootfs image
< waiting for any device >
[Tue Sep 25 17:59:17 2018] usb 2-3.1: new high-speed USB device number 22 using xhci_hcd
[Tue Sep 25 17:59:17 2018] usb 2-3.1: New USB device found, idVendor=18d1, idProduct=4e30, bcdDevice= 1.00
[Tue Sep 25 17:59:17 2018] usb 2-3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Tue Sep 25 17:59:17 2018] usb 2-3.1: Product: Android 1.0
[Tue Sep 25 17:59:17 2018] usb 2-3.1: Manufacturer: Google, Inc
[Tue Sep 25 17:59:17 2018] usb 2-3.1: SerialNumber: 014994B00C01A013
target didn't report max-download-size
Erasing 'system'...
OKAY [  0.047s]
Sending 'system' (369664 KB)...
OKAY [ 50.498s]
Writing 'system'...
OKAY [ 26.436s]
Finished. Total time: 77.024s
[18:00:02] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[18:00:02] Done
dpavlin@nuc:/nuc/pmbootstrap$ [Tue Sep 25 19:24:27 2018] usb 2-3.1: USB disconnect, device number 22
[Tue Sep 25 19:24:27 2018] usb 2-3.1: new high-speed USB device number 23 using xhci_hcd
[Tue Sep 25 19:24:27 2018] usb 2-3.1: unable to get BOS descriptor
[Tue Sep 25 19:24:27 2018] usb 2-3.1: New USB device found, idVendor=0451, idProduct=d010, bcdDevice= 0.00
[Tue Sep 25 19:24:27 2018] usb 2-3.1: New USB device strings: Mfr=33, Product=37, SerialNumber=0
[Tue Sep 25 19:24:27 2018] usb 2-3.1: Product: OMAP4440
[Tue Sep 25 19:24:27 2018] usb 2-3.1: Manufacturer: Texas Instruments
[Tue Sep 25 19:24:30 2018] usb 2-3.1: USB disconnect, device number 23
.pre

^ u-boot

* https://github.com/Ksys-labs/uboot-tuna
{image: load_detail1.jpg}

{file: dummy-load-sch.pdf}

ZHIYU ZPB30A1 60W dummy load

input voltage: 12V 0.5A (11-14V)
constant current: 0.20-9.99 A

* review https://youtu.be/snROh2acybs
* Reverse Engineering https://youtu.be/KYncNH8_m70
* 60W Dummy Load Mod 20mA to 999mA https://youtu.be/K-7kgfbH-eI



^ modes

hold run button at power on

Fun1 - dc load (continue working on voltage alarm)
Fun2 - battery test (stop load at specified voltage)8n

^ serial

115200 8n1

pins from bottom of the board upwards

G - GND
R - RX
T - TX
L - always low?
F - 50 Khz quare wave
Vc - input voltage

3 byte output, first two bytes are BCD voltage (3.35V) and last one is status (1=ok, 0=under voltage alarm)

.pre
pi@rpi2 ~ $ microcom -s 115200 -p /dev/ttyUSB4 | od -An -t x1 -w3
 04 35 01
*
 04 36 01
 04 35 01
*
 04 36 01
*
 04 35 01
*
 04 36 01
 04 35 01
.pre

^ replacement firmware

* https://github.com/ArduinoHannover/ZPB30A1_Firmware
{file: mount-rpi-image.sh}

{toc: }

{tag_list: raspberrypi}

^ Interestring projects

TODO: test them out and write full description on this wiki :-)

* FreeLSS is a laser scanning program for the Raspberry Pi. It allows a Raspberry Pi to function as the core to a complete turn table laser scanning system.
** https://github.com/hairu/freelss
* PWM on the Raspberry pi - done properly (in hardware, stable)
** https://github.com/sarfata/pi-blaster
* https://github.com/ali1234/raspi-teletext
* https://github.com/jgarff/rpi_ws281x

* u-boot on sdcard for nfs boot: http://elinux.org/RPi_U-Boot

* RF transmitter for Raspberry Pi https://github.com/F5OEO/rpitx

^ development

* distcc setup http://openframeworks.cc/setup/raspberrypi/Raspberry-Pi-DISTCC-guide.html
* RPi (Raspbian arm) chroot on x86 Linux http://dev.xff.lt/b/archives/2015/01/11/rpi_raspbian_arm_chroot_on_x86_linux/
** https://wiki.debian.org/QemuUserEmulation https://wiki.debian.org/RaspberryPi/qemu-user-static

^ [OV7670]

* http://www.raspberrypi.org/phpBB3/viewtopic.php?uid=25856&f=44&t=11839&start=0

^ DHT11/DHT22

* http://www.tortosaforum.com/raspberrypi/dht11driver.htm
* http://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/overview

^ [BlinkM] + i2c

* http://www.raspberrypi.org/forums/viewtopic.php?t=11969

^ CEC - control your TV

http://www.raspberrypi.org/forum/viewtopic.php?f=35&t=15749

.pre
root@raspberrypi:/home/pi# git clone https://github.com/Pulse-Eight/libcec.git
root@raspberrypi:/home/pi# cd libcec/
root@raspberrypi:/home/pi/libcec# apt-get install autoconf automake libtool liblockdev1-dev libudev-dev libraspberrypi-dev
root@raspberrypi:/home/pi/libcec# sh -x bootstrap
root@raspberrypi:/home/pi/libcec# ./configure --with-rpi-include-path=/opt/vc/include/ --with-rpi-lib-path=/opt/vc/lib/

##############################################################################

libCEC version 2:1:0 configured

Compilation flags:
  CXXFLAGS :       -g -O2 -fPIC -Wall -Wextra -Wno-missing-field-initializers  -Wno-psabi
  libCEC LDFLAGS : -lbcm_host -llockdev -lrt -ldl -lpthread  -L/opt/vc/lib/ -lvcos -lvchiq_arm -ludev  
  client LDFLAGS : -lrt -ldl -lpthread 

Configured features:
  Pulse-Eight CEC Adapter :             yes
  Pulse-Eight CEC Adapter detection :   yes
  Raspberry Pi support :                yes
  TDA995x support :                     no

You can now build libCEC by running:
  make

##############################################################################

make install
.pre

^^ TV on

.pre
pi@raspberrypi ~ $ echo "on 0" | cec-client -s
.pre

^ Hints from forum

^^ screen saver

http://www.raspberrypi.org/phpBB3/viewtopic.php?p=84831#p84831

.pre
# prevent screensaver from powering down display
setterm -blank 0 -powerdown 0 > /dev/tty0

# clear the display and turn off the flashing cursor
clear > /dev/tty0
setterm -cursor 0 > /dev/tty0

# turn the cursor back on when done with omxplayer
setterm -cursor 1 > /dev/tty0
.pre

^^ YouTube transcoding in VLC

http://www.raspberrypi.org/phpBB3/viewtopic.php?p=163658#p163658

.pre
cvlc 'youtube.com/watch?v=XXXXXXXXXX' :sout='#transcode{vcodec=h264,vb=0,fps=0,scale=0,height=720,acodec=mp4a,ab=128,channels=2,samplerate=44100}:http{mux=ffmpeg{mux=flv},dst=:8080/youtube}' :sout-keep
.pre

^ Education materials

* http://pi.cs.man.ac.uk/download/Raspberry_Pi_Education_Manual.pdf
* http://www.ocr.org.uk/qualifications/by-subject/computing/raspberry-pi/
* http://www.cl.cam.ac.uk/projects/raspberrypi/

^ Raspberry Pi Accessories Starter Kit

http://www.conrad.com/ce/en/product/409208/Raspberry-Pi-Accessories-Starter-Kit?ref=searchDetail

* 1x Rapberry sticker

* Power supply for the Raspberry
* Sturdy acrylic housing, which includes all possible connections for this Raspberry and perfectly protects
* 4 GB SD card to store your programs
** https://learn.adafruit.com/adafruit-raspberry-pi-lesson-1-preparing-and-sd-card-for-your-raspberry-pi
* USB Micro Card Reader
* USB cable (for power supply or the power supply of a PC)
* 3 m Ethernet cable
** https://learn.adafruit.com/adafruits-raspberry-pi-lesson-6-using-ssh
** https://learn.adafruit.com/adafruit-raspberry-pi-lesson-7-remote-control-with-vnc
* TTL USB cable
** https://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-console-cable/test-and-configure
* PI Cobbler (KIT hereby connect the RP with other circuit boards)
* Large breadboard circuit
* Colored board cable connector

* 5x 560 ohm resistors (for LEDS)
* 3x LED's (red, green, blue)
** https://learn.adafruit.com/raspberry-pi-e-mail-notifier-using-leds
** https://learn.adafruit.com/debugging-with-the-raspberry-pi-webide/debug-a-blinking-led
* 5x 10K resistors (for buttons)
* 3x pushbutton
** https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/bread-board-setup-for-input-buttons
* 1x photocell
** https://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi/basic-photocell-reading
* 1x 1uf capacitor (for photocell)

^ GPU

* FFT
** http://www.raspberrypi.org/accelerating-fourier-transforms-using-the-gpu/
** https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/hello_pi/hello_fft/qasm
* SHA-256
** http://rpiplayground.wordpress.com/
** https://github.com/elorimer/rpi-playground/tree/master/QPU
* Machine learning - the Deep Belief image recognition SDK
** http://petewarden.com/2014/06/09/deep-learning-on-the-raspberry-pi/
** http://scientistnobee.wordpress.com/2014/06/20/machine-learning-with-raspberry-pi/

^ Arduino

* Connect using I2C http://www.pihomeserver.fr/en/2013/08/13/raspberry-pi-home-server-arduino-lier-les-deux-via-bus-i2c/

^ JTAG

* https://github.com/synthetos/PiOCD/wiki/Using-a-Raspberry-Pi-as-a-JTAG-Dongle

^ Arduino ProMini 3.3V 8MHz

^^ Disable serial port console

edit `/boot/cmdline.txt` and remove all ttyAMA0 leaving:

.pre
pi@raspberrypi ~ $ cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait bcm2708.w1_gpio_pin=4
.pre

also, comment out ttyAMA0 in `/etc/inittab`

^^ connect Arduino serial

RX->TX
TX->RX

https://github.com/dpavlin/avrdude-rpi/tree/fix_channel_in_use

pin definitions in GPIO.RPi are physical pins on board *not* BCM or wiring ip!

{image: gpio1.png}

^^ flasing

.pre
dpavlin@blue:~/Arduino/RF433_Sockets$ scp /tmp/build*.tmp/*.hex pi@rpi.tv:/tmp/
RF433_Sockets.cpp.hex                                        100%   19KB  18.6KB/s   00:00

pi@raspberrypi ~ $ cat avrdude.sh 
#!/bin/sh
hex=`ls -t /tmp/*.hex | head -1`
echo "flash hex: $hex"
sudo /home/pi/avrdude-rpi/avrdude-autoreset -C /home/pi/avrdude.conf -v -v -patmega328p -carduino -P/dev/ttyAMA0 -b57600 -D -Uflash:w:$hex:i 

pi@raspberrypi ~ $ ./avrdude.sh
flash hex: /tmp/RF433_Sockets.cpp.hex

avrdude: Version 6.1, compiled on Sep 17 2014 at 05:41:35
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/pi/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyAMA0
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
done with autoreset
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "/tmp/RF433_Sockets.cpp.hex"
avrdude: writing flash (6770 bytes):

Writing | ################################################## | 100% 1.98s

avrdude: 6770 bytes of flash written
avrdude: verifying flash memory against /tmp/RF433_Sockets.cpp.hex:
avrdude: load data flash data from input file /tmp/RF433_Sockets.cpp.hex:
avrdude: input file /tmp/RF433_Sockets.cpp.hex contains 6770 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.49s

avrdude: verifying ...
avrdude: 6770 bytes of flash verified

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe

avrdude done.  Thank you.

strace: |/home/pi/avrdude-rpi/autoreset: Broken pipe
.pre

^ DS1307 Tiny RTC

* http://www.instructables.com/id/Set-up-Real-Time-Clock-RTC-on-Raspberry-Pi/
* http://electronics.stackexchange.com/questions/98361/how-to-modify-ds1307-rtc-to-use-3-3v-for-raspberry-pi

Check if module has 5V pull-up I2C resistors! If it does (like Tiny RTC has R2 and R3) you will have to remove them.

{image: tiny-rtc-3.3v-remote-r2-r3.jpg}

.pre
root@raspberrypi:/home/pi# apt-get install i2c-tools

root@raspberrypi:/home/pi# modprobe i2c-dev

root@raspberrypi:/home/pi# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

root@raspberrypi:/home/pi# modprobe rtc-ds1307

root@raspberrypi:/home/pi# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

root@raspberrypi:/home/pi# hwclock --systohc -D --noadjfile --utc
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Assuming hardware clock is kept in UTC time.
Time elapsed since reference time has been 0.722720 seconds.
Delaying further to reach the new time.
Setting Hardware Clock to 11:53:41 = 1429876421 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
.pre

^^ DS18B20

.pre
root@raspberrypi:/home/pi# grep w1 /boot/config.txt 
dtoverlay=w1-gpio

# reboot

root@raspberrypi:/home/pi# cat /sys/bus/w1/devices/28-0000043c5507/w1_slave 
50 05 4b 46 7f ff 0c 10 1c : crc=1c YES
50 05 4b 46 7f ff 0c 10 1c t=85000
.pre

Hmm, you will also want to remove R1 pullup to make it work?

^ avrdude

Using Raspberry Pi as Arduino ISP programmer

* https://github.com/onandoffables/avrdude-linuxgpio

.pre
root@raspberrypi:/home/pi# avrdude -c linuxgpio -p atmega328p

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f

avrdude: safemode: Fuses OK (E:05, H:DA, L:FF)

avrdude done.  Thank you.
.pre

^ logic analyzer

* bare metal: https://github.com/tuxyme/metal-pi
* Panalyzer - a RaspberryPi based Logic Analyzer https://github.com/richardghirst/Panalyzer

^ rotary encoder

http://www.bobrathbone.com/raspberrypi_rotary.htm

^ SWD

http://www.disk91.com/2015/technology/programming/swd-programming-using-a-raspberrypi/
https://github.com/disk91/PySWD

.pre
pi@raspberrypi ~ $ git clone https://github.com/disk91/PySWD
pi@raspberrypi ~ $ cd PySWD/

.pre

^ PIC

* rpp - PIC Programmer using GPIO http://holdenc.altervista.org/rpp/
* http://mujweb.cz/tlc/rpp/
* https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=14689&start=75
* https://github.com/oh7bf/PiPIC
* https://github.com/WallaceIT/picberry

^ esp8089

* https://hackaday.io/project/8678-rpi-wifi-hat
* https://github.com/al177/esp8089

^ PS/2 GPIO

* http://www.deater.net/weave/vmwprod/hardware/pi-ps2/
** https://github.com/deater/vmw-meter/blob/master/pi-ps2/linux-kernel/pi-ps2gpio.c

^ GPIO header annotations

* https://github.com/splitbrain/rpibplusleaf/tree/master

^ Signal generator

* https://github.com/JamesP6000/WsprryPi

.pre
pi@rpi2 ~/WsprryPi $ sudo ./wspr --test-tone 1000000
A test tone will be generated at frequency 1.000000 MHz

Using local mbox device file with major 249.
Transmitting test tone on frequency 1.000000 MHz
Press CTRL-C to exit!
.pre

* http://github.com/gryrmln/RPi_Wobbulator

^ LCD panels

http://blog.reasonablycorrect.com/raw-dpi-raspberry-pi/

^ Pi Zero USB OTG

libcomposite

* http://isticktoit.net/?p=1383

^ PATA IDE emulation

* https://www.retrotronics.org/home-page/netpi-ide/

^ DPI LCD screen

* http://blog.reasonablycorrect.com/raw-dpi-raspberry-pi/
* https://www.raspberrypi.org/forums/viewtopic.php?p=1023780#p1023780

^ i2c clock stretching

* https://github.com/raspberrypi/linux/issues/254#issuecomment-217047171
 
{file: RM-1}

* http://www.wrotniak.net/photo/c/c5050-rev.html

^ RM-1 remote

http://lirc.sourceforge.net/remotes/olympus/RM-1
^ links

* https://github.com/DavidBuchanan314/wifi-sdcf - this exact card, includes sd card emulator, but no client for real card


* https://habr.com/post/216039/ - something similar for transcend in russian
** https://github.com/kaist/shoot-and-view

^ info

WIFI Adapter Memory Card TF Micro-SD to CF Compact Flash Card Kit for Digit Y8X8

Insert your Micro-SD HC card into WiFi CF adapter and you can access high quality photos and videos sent wirelessly from your camera via Wi-Fi to your Smartphone or tablet to share.
Supports "with the beat-per-view" feature and both Apple Ios & Android devices
WiFi-CF settings: WiFi password,AP Mode and Station Mode switch, IP, channels, number or users, SSID.
some camera don't support wifi function, then the wifi unavailable. 
Please check the camera manual before you use the wifi function. 
Insert your Micro-SD HC card into WiFi CF adapter and you can access high 
quality photos and videos sent wirelessly from your camera via Wi-Fi to 
your Smartphone or tablet to share. 
1.Connect up to 3 devices simultaneously 
2.Supports "with the beat-per-view" feature. 
3.Supports both Apple Ios & Android devices. 
4.WiFi-CF settings: WiFi password,AP Mode and Station Mode switch, IP, 
channels, number or users, SSID. 
5. Please choose the quality,performance,higher microSDHC Card(recommend 
Class 10). 
6. Capacity: based on your microSDHC / microSDXC card. 
7. SD browse file formats supported: 
1) Photo (photo): JPG,PNG,BMP. 
2) Video(Video): MP4,AVI,MOV. 
3) Music(Music): MP3,WAV. 
Note: WiFi-CF can display above file formats,but the ability to play 
depends on whether the Wi-Fi device you use can support. 
WIFI-CF Default Password: 999999 or 99999999 
WIFI-CF Apps Default Username: admin 
WIFI-CF Apps Default Password: admin
colour: black+white
Material: ABS
Package Contents: 
1*WIFI Adapter Memory Card 
Note: WiFi-CF can display above file formats,but the ability to play depends on whether the Wi-Fi device you use can support.
The TF Micro-SD memory card is not included.
Only the above package content, other products are not included.
Note: Light shooting and different displays may cause the color of the item in t
^ Overview

STM32F107 RBT6 + QCA8337 AL3C based router with serial and swd headers

* https://www.st.com/en/microcontrollers/stm32f107rb.html

Mainstream Connectivity line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, Ethernet MAC, CAN and USB 2.0 OTG



^ Firmware

According to https://wiki.mikrotik.com/wiki/SwOS/RB250_RB260#Summary

new RB260GS (CSS106-5G-1S), new RB260GSP(CSS106-1G-4P-1S) supports SwOS v2.0 and newer.

Example working (as of 2018-07-06) url download links which work for CSS106-5G-1S:

https://download2.mikrotik.com/swos2/css106/swos-css1061g4p1s-2.0.bin
https://download2.mikrotik.com/swos2/css106/swos-css1061g4p1s-2.2.bin

.pre
dpavlin@lib10:/lib10/arh-hw/backup/Mikrotik-RB260GS-CSS106-5G-1S/rb260gsp$ md5sum *
bf110ca7e1cd0558cefeacd9e0b62c19  swos-css1061g4p1s-2.0.bin
a491bbf2732937839e6a8222a876cc7a  swos-css1061g4p1s-2.2.bin
f098106dfc8ac5ad0fedf0181c68d8de  swos-css1061g4p1s-2.3.bin
f4f74f697039a83baa99d37017251805  swos-css1061g4p1s-2.4.bin
90d2ec8571dd9d9aeab1bfbaaa99dea2  swos-css1061g4p1s-2.5.bin
a7f046fc8a12b5ebeb85f9a4bb0dd275  swos-css1061g4p1s-2.6.bin
a1e7adc6ad63e5560156b0f2b6f272ce  swos-css1061g4p1s-2.7.bin



.pre

^^ version

from web interface

.pre
Firmware
Current Installed Version	2.7 (built at Fri Dec 15 2017 09:42:48 GMT+0100 (CET))
Latest Available Version	2.7 (built at Fri Dec 15 2017 09:42:48 GMT+0100 (CET))
.pre

^ reset

* hold reset while poweron

SwOS v2.x - RB260GS(CSS106-5G-1S) and RB260GSP(CSS106-1G-4P-1S)

The new RB260GS(CSS106-5G-1S) and RB260GSP(CSS106-1G-4P-1S) has built-in backup SwOS firmware which can be loaded in case standard firmware breaks or upgrade fails:

    Holding Reset button for few seconds while device is booting resets configuration and loads backup firmware SwOS 2.0p.
    After loading backup firmware SwOS 2.0p it is possible to connect to 192.168.88.1 using web browser and install new SwOS firmware.

^^ default ip: 192.168.88.1

.pre
Current Installed Version	2.0p (built at Fri Oct 21 2016 10:18:39 GMT+0200 (CEST))
Latest Available Version	2.7 (built at Fri Dec 15 2017 09:42:48 GMT+0100 (CET))


.pre

After this, router knows that there is new version, but can't download it from http://upgrade.mikrotik.com/swos2/css106/swos-css106-2.7.bin

^ Linux setup

.pre
dpavlin@x230:~$ sudo ifconfig enp0s25 192.168.88.240


wget --http-user=admin --http-password='' 'http://192.168.88.1/!stats.b'


.pre
{file: cubieboard_schematic_2012-08-08.pdf}

{file: BreadBoard V1.0 03-25 For CubieBoard.pdf}

{toc: }

^ A20

* Debian image sunxi_ss crypto http://www.cubieforums.com/index.php/topic,1275.0.html
* http://www.armbian.com/cubieboard-2/

^ Running UBI/UBIFS on MLC NAND

* https://events.static.linuxfound.org/sites/events/files/slides/ubi-mlc.pdf
* https://youtu.be/9j2pOIiJqYw

^ NAND in mainline kernel

* http://linux-sunxi.org/Mainline_NAND_Howto
* http://linux-sunxi.org/MTD_Driver

Samsung K9GBG08U0A NAND

* https://groups.google.com/forum/#!topic/linux-sunxi/PxMmiCe0Deg
* https://www.netdevconf.org/2.1/papers/distributed-switch-architecture.pdf

.pre
dpavlin@cubieboard:~$ dmesg | grep -A 5 nand
[    4.395437] nand: Could not find valid JEDEC parameter page; aborting
[    4.401898] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xd7
[    4.408272] nand: Samsung NAND 4GiB 3,3V 8-bit
[    4.412719] nand: 4096 MiB, MLC, erase size: 1024 KiB, page size: 8192, OOB size: 640
[    4.421299] Bad block table found at page 524160, version 0x25
[    4.427987] Bad block table found at page 524032, version 0x25
[    4.434238] nand_read_bbt: bad block at 0x000001000000
[    4.439379] nand_read_bbt: bad block at 0x000001100000
[    4.445411] 6 ofpart partitions found on MTD device 1c03000.nand
[    4.451420] Creating 6 MTD partitions on "1c03000.nand":
[    4.456769] 0x000000a00000-0x0001ffa00000 : "rootfs"
[    4.461737] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[    4.472910] 0x000001000000-0x000001400000 : "env"
[    4.477926] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[    4.483748] 0x000000800000-0x000000c00000 : "U-Boot"
[    4.488997] 0x000000400000-0x000000800000 : "SPL.backup"
[    4.494580] 0x000000000000-0x000000400000 : "SPL"



dpavlin@cubieboard2:~$ dmesg | grep -A 5 nand
[    4.709427] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xd7
[    4.715876] nand: Hynix H27UBG8T2BTR-BC 32G 3.3V 8-bit
[    4.721021] nand: 4096 MiB, MLC, erase size: 2048 KiB, page size: 8192, OOB size: 640
[    4.728997] Scanning device for bad blocks
[    8.484659] 6 ofpart partitions found on MTD device 1c03000.nand
[    8.490678] Creating 6 MTD partitions on "1c03000.nand":
[    8.496021] 0x000000a00000-0x0001ffa00000 : "rootfs"
[    8.500992] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[    8.515527] 0x000001000000-0x000001400000 : "env"
[    8.520564] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[    8.526504] 0x000000800000-0x000000c00000 : "U-Boot"
[    8.531755] 0x000000400000-0x000000800000 : "SPL.backup"
[    8.537395] 0x000000000000-0x000000400000 : "SPL"
.pre

^^ many bad blocks

http://linux-sunxi.org/Mainline_NAND_Howto#Many_bad_blocks

To fix many bad blocks issue you should:

1. Disable nand-on-flash-bbt in your dts
2. Remove this test: http://lxr.free-electrons.com/source/drivers/mtd/nand/nand_base.c?v=4.7#L2940
3. Boot your new kernel and erase chip with flash_erase /dev/mtd[0-X]
4. Re-introduce the bad block check removed in 2, re-enable nand-on-flash-bbt
   and boot the new kernel

Let's try to do this with armbian.

^^^ cubieboard

First, enable nand overlay

.pre
dpavlin@cubieboard:~$ cat /boot/armbianEnv.txt
overlays=nand
.pre

Then remove nand-om-flash-btt:

.pre
dpavlin@cubieboard:/$ cd /boot/dtb-`uname -r`/overlay
dpavlin@cubieboard:/boot/dtb-4.14.23-sunxi/overlay$ 

# backup original
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# cp sun4i-a10-nand.dtbo sun4i-a10-nand.dtbo.orig

# remote nand-on-flash-bbt
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# dtc -I dtb -O dts sun4i-a10-nand.dtbo | grep -v nand-on-flash-bbt > /tmp/nand.dts
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# dtc -I dts -O dtb /tmp/nand.dts > sun4i-a10-nand.dtbo
.pre

Compile armbian kernel with this patch applied

.pre
dpavlin@armbian:~/build$ cp ./patch/kernel/sunxi-dev/nand-disable-badblock-check-for-migration.patch.disabled \
    ./userpatches/kernel/sunxi-next/nand-disable-badblock-check-for-migration.patch
.pre

Reboot and check that nand is available:

.pre
dpavlin@cubieboard:~$ dmesg | grep -A 8 MTD
[   13.696198] 6 ofpart partitions found on MTD device 1c03000.nand
[   13.702205] Creating 6 MTD partitions on "1c03000.nand":
[   13.707550] 0x000000a00000-0x0001ffa00000 : "rootfs"
[   13.712517] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[   13.723693] 0x000001000000-0x000001400000 : "env"
[   13.728713] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[   13.734568] 0x000000800000-0x000000c00000 : "U-Boot"
[   13.739778] 0x000000400000-0x000000800000 : "SPL.backup"
[   13.745368] 0x000000000000-0x000000400000 : "SPL"
[   13.751476] sun4i-mdio 1c0b080.mdio: 1c0b080.mdio supply phy not found, using dummy regulator
.pre

Now init nand:

.pre
root@cubieboard:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 1048576 (1M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0


root@cubieboard2:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 2097152 (2M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0

root@cubieboard:/home/dpavlin# flash_erase /dev/mtd0 0 0
Erasing 1024 Kibyte @ 600000 --  0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 6 (mtd0)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd0: MTD Erase failure
             error 5 (Input/output error)
Erasing 1024 Kibyte @ 700000 --  0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 7 (mtd0)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd0: MTD Erase failure
             error 5 (Input/output error)
Erasing 1024 Kibyte @ ff500000 -- 100 % complete 


root@cubieboard:/home/dpavlin# ubiformat /dev/mtd0
ubiformat: mtd0 (mlc-nand), size 4284481536 bytes (4.0 GiB), 4086 eraseblocks of 1048576 bytes (1024.0 KiB), min. I/O size 8192 bytes
libscan: scanning eraseblock 4085 -- 100 % complete  
ubiformat: 4084 eraseblocks are supposedly empty
ubiformat: warning!: 2 of 4086 eraseblocks contain non-UBI data
ubiformat: continue? (y/N) y
ubiformat: warning!: only 0 of 4086 eraseblocks have valid erase counter
ubiformat: erase counter 0 will be used for all eraseblocks
ubiformat: note, arbitrary erase counter value may be specified using -e option
ubiformat: continue? (y/N) y
ubiformat: use erase counter 0 for all eraseblocks
ubiformat: formatting eraseblock 6 --  0 % complete  libmtd: error!: MEMERASE64 ioctl failed for eraseblock 6 (mtd0)
        error 5 (Input/output error)

ubiformat: error!: failed to erase eraseblock 6
           error 5 (Input/output error)
ubiformat: mark it as bad? (y/N) y
ubiformat: marking block 6 bad
ubiformat: formatting eraseblock 7 --  0 % complete  libmtd: error!: MEMERASE64 ioctl failed for eraseblock 7 (mtd0)
        error 5 (Input/output error)

ubiformat: error!: failed to erase eraseblock 7
           error 5 (Input/output error)
ubiformat: mark it as bad? (y/N) y
ubiformat: marking block 7 bad
ubiformat: formatting eraseblock 4085 -- 100 % complete  




ubiattach -p /dev/mtd0

ubimkvol /dev/ubi0 -s 2GiB -N root

mount /dev/ubi0_0 /mnt/ -t ubifs

root@cubieboard:~# mount /dev/ubi0_0 /mnt/ -t ubifs
[Wed Feb 28 17:49:38 2018] UBIFS error (pid: 4709): cannot open "/dev/ubi0:root", error -22
[Wed Feb 28 17:49:43 2018] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 4722
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "root"
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): LEB size: 1032192 bytes (1008 KiB), min./max. I/O unit sizes: 8192 bytes/8192 bytes
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): FS size: 2137669632 bytes (2038 MiB, 2071 LEBs), journal size 33030144 bytes (31 MiB, 32 LEBs)
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 8E9A30F0-241F-4013-916F-C0B995F22BB1, small LPT model

.pre

^^^ cubieboard2

This is mostly redundant from cubieboard, but with attempt to define mtd partitions correctly

.pre
root@cubieboard2:/home/dpavlin# ubiformat /dev/mtd0
ubiformat: mtd0 (mlc-nand), size 4273995776 bytes (4.0 GiB), 2038 eraseblocks of 2097152 bytes (2.0 MiB), min. I/O size 8192 bytes
libscan: scanning eraseblock 2037 -- 100 % complete  
ubiformat: 2038 eraseblocks have valid erase counter, mean value is 1
ubiformat: formatting eraseblock 2037 -- 100 % complete  


.pre

^^ mount ubifs filesystem

.pre
dpavlin@cubieboard:~$ grep ubi /mnt/boot/armbianEnv.txt
rootdev=ubi0:root ubi.mtd=0
rootfstype=ubifs

dpavlin@cubieboard:~$ grep ubi /etc/fstab 
ubi0:root / ubifs defaults,noatime,nodiratime 0 1
.pre

^ u-boot

Original u-boot output

.pre
HELLO! BOOT0 is starting!
boot0 version : 1.5.1
dram size =1024
Succeed in opening nand flash.
Succeed in reading Boot1 file head.
The size of Boot1 is 0x0003c000.
The file stored in 0X00000000 of block 2 is perfect.
Check is correct.
Ready to disable icache.
Succeed in loading Boot1.
Jump to Boot1.
[       0.133] boot1 version : 1.4.0
[       0.133] pmu type = 3
[       0.134] bat vol = 0
[       0.161] axi:ahb:apb=3:2:2
[       0.161] set dcdc2=1400, clock=1008 successed
[       0.163] key
[       0.175] no key found
[       0.175] flash init start
[       4.051] flash init finish
[       4.052] fs init ok
[       4.053] fattype FAT16
[       4.053] fs mount ok
[       4.060] script finish
[       4.061] power finish
[       4.069] BootMain start
[       4.069] 13
[       4.089] key value = 0
[       4.089] recovery key high 6, low 4
[       4.090] unable to find fastboot_key key_max value
[       4.098] test for multi os boot with display
[       4.100] show pic finish
[       4.103] load kernel start
[       4.127] load kernel successed
[       4.127] start address = 0x4a00000

U-Boot 2011.09-rc1 (Nov 26 2012 - 14:01:52) Allwinner Technology 

CPU:   SUNXI Family
Board: A10-EVB
DRAM:  512 MiB
NAND:  3776 MiB
In:    serial
Out:   serial
Err:   serial
--------fastboot partitions--------
-total partitions:11-
-name-        -start-       -size-      
bootloader  : 1000000       1000000     
env         : 2000000       1000000     
boot        : 3000000       2000000     
system      : 5000000       14000000    
data        : 19000000      20000000    
misc        : 39000000      1000000     
recovery    : 3a000000      2000000     
cache       : 3c000000      8000000     
private     : 44000000      1000000     
sysrecovery : 45000000      14000000    
UDISK       : 59000000      93000000    
-----------------------------------
Hit any key to stop autoboot:  0 
sunxi#
.pre

^^ compile with nand support

* https://groups.google.com/forum/#!topic/linux-sunxi/PxMmiCe0Deg

On Cubieboard2 with those patches we get:

.pre
=> nand info

Device 0: nand0, sector size 2048 KiB
  Page size       8192 b
  OOB size         640 b
  Erase size   2097152 b
  subpagesize     8192 b
  options     0x00001000
  bbt options 0x00070000

# which comparted to booted linux kernel with mtd support....

root@cubieboard2:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 2097152 (2M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0

# it looks somewhat OK, but mtdparts doesn't (yet) return anything.
.pre

Another day, another try to get mtdparts to display something...

.pre
root@armbian:~/build/cache/sources/u-boot/v2017.11# grep -i mtd .config
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nand0=sunxi-nand"
CONFIG_MTDPARTS_DEFAULT="mtdparts=sunxi-nand:4m(spl),4m(spl-backup),4m(uboot),4m(uboot-backup),4m(env),-(UBI)"
# CONFIG_CMD_MTDPARTS_SPREAD is not set
# MTD Support
CONFIG_MTD=y
# CONFIG_MTD_NOR_FLASH is not set
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
# CONFIG_MTD_UBI_FASTMAP is not set

=> mtdparts

device nand0 <sunxi-nand>, # parts = 6
 #: name                size            offset          mask_flags
 0: spl                 0x00400000      0x00000000      0
 1: spl-backup          0x00400000      0x00400000      0
 2: uboot               0x00400000      0x00800000      0
 3: uboot-backup        0x00400000      0x00c00000      0
 4: env                 0x00400000      0x01000000      0
 5: UBI                 0xfec00000      0x01400000      0

active partition: nand0,0 - (spl) 0x00400000 @ 0x00000000

defaults:
mtdids  : nand0=sunxi-nand
mtdparts: mtdparts=sunxi-nand:4m(spl),4m(spl-backup),4m(uboot),4m(uboot-backup),4m(env),-(UBI)






.pre

Instructions after this are hit-or-miss...

.pre
dpavlin@klin:/klin/u-boot$ cp configs/Cubieboard_defconfig .config

# add NAND, MTD options, A10 for cubieboard1

# compile while defining flash:

dpavlin@klin:/klin/u-boot$ cat build-cubieboard.sh 
# parametars are probably wrong for your chip!
make V=1 CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH=40 CONFIG_SYS_NAND_PAGE_SIZE=4036 CONFIG_SYS_NAND_OOBSIZE=640 CONFIG_SYS_NAND_BLOCK_SIZE=0x100000


dpavlin@cubieboard:~$ scp 10.60.0.92:/klin/u-boot/u-boot*spl* .

dpavlin@cubieboard:~$ sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8 
488+1 records in
488+1 records out
500154 bytes (500 kB) copied, 0.0423498 s, 11.8 MB/s

.pre

It would be better to define params in u-boot config file like:

.pre
CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCK_SIZE=0x40000,SYS_NAND_PAGE_SIZE=4096,SYS_NAND_OOBSIZE=256"
.pre

(with correct values of course).

^ pinout

* http://docs.cubieboard.org/cubieboard1_and_cubieboard2_gpio_pin

^^ U14 (Next to SATA connector)

|  | *SPI0* |
| 48 | PI13 (SPI0-MISO/UART6-RX/EINT25) | 47 | PI11 (SPI0-CLK/UART5-RX/EINT23) |
| 46 | PI12 (SPI0-MOSI/UART6-TX/EINT24) | 45 | PI10 (SPI0-CS/UART5-TX/EINT22) |
|  | *LCD* |
| 44 | 3.3V (nc in 2012-08-08) | 43 | VCC-5V |
| 42 | Ground | 41 | SPDIF |
| 40 | PB10 (LCD0-SCK/LCD-PIO1) | 39 | PB11 (LCD0-SDA/LCD-PIO2) |
| 38 | Ground | 37 | PH7 (LCD0-BL-EN/LCD-PIO0/UART5-RX/EINT7) |
| 36 | XN_TP (TP-X2) | 35 | YN_TP (TP-Y2) |
| 34 | XP_TP (TP-X1) | 33 | YP_TP (TP-Y1) |
| 32 | PD25 (LCDDE) | 31 | PB2 (PWM0) |
| 30 | PD26 (LCDHSYNC)-VGA-HSYNC | 29 | PD24 (LCDCLK) |
| 28 | PD23 (LCDD23) | 27 | PD27 (LCDVSYNC)-VGA-VSYNC |
| 26 | PD21 (LCDD21) | 25 | PD22 (LCDD22) |
| 24 | PD19 (LCDD19/LVDS1N3) | 23 | PD20 (LCDD20) |
| 22 | PD17 (LCDD17/LVDS1NC) | 21 | PD18 (LCDD18/LVDS1P3) |
| 20 | Ground | 19 | PD16 (LCDD16/LVDS1PC) |
| 18 | PD14 (LCDD14/LVDS1P2) | 17 | PD15 (LCDD15/LVDS1N2) |
| 16 | PD12 (LCDD12/LVDS1P1) | 15 | PD13 (LCDD13/LVDS1N1) |
| 14 | PD10 (LCDD10/LVDS1P0) | 13 | PD11 (LCDD11/LVDS1N0) |
| 12 | PD8 (LCDD8/LVDS0P3) | 11 | PD9 (LCDD9/LVDS0N3) |
| 10 | PD7 (LCDD7/LVDS0NC) | 9 | Ground |
| 8 | PD5 (LCDD5/LVDS0N2) | 7 | PD6 (LCDD6/LVDS0PC) |
| 6 | PD3 (LCDD3/LVDS0N1) | 5 | PD4 (LCDD4/LNVS0P2) |
| 4 | PD1 (LCDD1/LVDS0N0) | 3 | PD2 (LCDD2/LVDS0P1) |
| 2 | Ground | 1 | PD0 (LCDD0/LVDSP0) |

^^ U15 (Between Ethernet port and USB ports)

|  | *CSI1/TS* |
| 1 | VCC-5V | 2 | PH15 (CSI1-PWR/EINT15) |
| 3 | CSI1-IO-2V8 | 4 | PH14 (CSI1-RST#/EINT14) |
| 5 | PG0 (CSI1-PCLK/SDC1-CMD) | 6 | PB18 (TWI1-SCK) |
| 7 | PB19 (TWI1-SDA) | 8 | PG3 (CSI1-VSYNC/SDC1-D1) |
| 9 | PG2 (CSI1-HSYNC/SDC1-D0) | 10 | PG1 (CSI1-MCLK/SDC1-CLK) |
| 11 | PG4 (CSI1-D0/SDC1-D2) | 12 | PG5 (CSI1-D1/SDC1-D3) |
| 13 | PG6 (CSI1-D2/UART3-TX) | 14 | PG7 (CSI1-D3/UART3-RX |
| 15 | PG8 (CSI1-D4/UART3-RTS) | 16 | PG9 (CSI1-D5/UART3-CTS) |
| 17 | PG10 (CSI1-D6/UART4-TX) | 18 | PG11 (CSI1-D7/UART4-RX) |
| 19 | Ground | 20 | Ground |
|  | *Analog* *SDIO3* |
| 21 | FMINL | 22 | PI4 (SDC3-CMD) |
| 23 | FMINR | 24 | PI5 (SDC3-CLK) |
| 25 | Ground | 26 | PI6 (SDC3-D0) |
| 27 | VGA-R | 28 | PI7 (SDC3-D1) |
| 29 | VGA-G | 30 | PI8 (SDC3-D2) |
| 31 | VGA-B | 32 | PI9 (SDC3-D3) |
|  | *CSI0/TS* |
| 33 | LCD1-VSYNC | 34 | PE4 (CSI0-D0) |
| 35 | LCD1-HSYNC | 36 | PE5 (CSI0-D1) |
| 37 | Ground | 38 | PE6 (CSI0-D2) |
| 39 | AVCC | 40 | PE7 (CSI0-D3) |
| 41 | LRADC0 | 42 | PE8 (CSI0-D4) |
| 43 | CVBS | 44 | PE9 (CSI0-D5) |
| 45 | HPL | 46 | PE10 (CSI0-D6) |
| 47 | HPR | 48 | PE11 (CSI0-D7) |

----

everything below line is for legacy kernel and quite old

^ disk speed

^^ NAND

.pre
root@cubieboard2:/home/dpavlin# uname -a
Linux cubieboard2 3.4.109-sun7i #4 SMP PREEMPT Sun Oct 11 14:32:15 CEST 2015 armv7l GNU/Linux
root@cubieboard2:/home/dpavlin# hdparm -t /dev/nand

/dev/nand:
 Timing buffered disk reads:  32 MB in  3.22 seconds =   9.94 MB/sec

# this is different, faster sdcard
root@cubieboard2:~# uname -a
Linux cubieboard2 4.3.3-sunxi #3 SMP Mon Dec 28 11:27:16 CET 2015 armv7l GNU/Linux
root@cubieboard2:~# hdparm -tT /dev/mmcblk0

/dev/mmcblk0:
 Timing cached reads:   770 MB in  2.00 seconds = 384.59 MB/sec
 Timing buffered disk reads:  60 MB in  3.05 seconds =  19.67 MB/sec


.pre

^^ SATA

Powered by 2A Nexus 7 power supply (for SATA)

https://groups.google.com/d/searchin/cubieboard/sata/cubieboard/hKJgJneGVmQ/xme3w4Y7XtsJ?fromplusone=1

.pre
root@debian:~/sunxi-tools# ./bin2fex /boot/script.bin script.fex
fexc-bin: /boot/script.bin: version: 0.1.2
fexc-bin: /boot/script.bin: size: 42144 (76 sections)

root@debian:~/sunxi-tools# cp script.fex script+sata.fex

root@debian:~/sunxi-tools# diff -urw script.fex script+sata.fex 
--- script.fex  2013-05-30 10:41:13.979510762 +0000
+++ script+sata.fex     2013-05-30 10:42:36.380244101 +0000
@@ -595,7 +595,7 @@
 
 [sata_para]
 sata_used = 1
-sata_power_en =
+sata_power_en = port:PB08<1><default><default><0>
 
 [mmc0_para]
 sdc_used = 1

root@debian:~/sunxi-tools# ./fex2bin script+sata.fex /boot/script.bin

root@debian:/etc# git diff
diff --git a/modules b/modules
index d8894c3..9e65a80 100644
--- a/modules
+++ b/modules
@@ -4,3 +4,4 @@
 # at boot time, one per line. Lines beginning with "#" are ignored.
 # Parameters can be specified after the module name.
 
+sw_ahci_platform
.pre

Reboot to activate changes and test speed (using 80G intel SSD to have sense of maximum performance)

.pre
root@debian:~# hdparm -i /dev/sda

/dev/sda:

 Model=INTEL SSDSA2M080G2GC, FwRev=2CV102HD, SerialNo=CVPO035101VN080JGN
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=1
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: ATA/ATAPI-7 T13 1532D revision 1:  ATA/ATAPI-2,3,4,5,6,7

 * signifies the current active mode

root@debian:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   784 MB in  2.00 seconds = 392.08 MB/sec
 Timing buffered disk reads: 460 MB in  3.00 seconds = 153.32 MB/sec
.pre

And test with disk:

.pre
root@debian:~# hdparm -i /dev/sda

/dev/sda:

 Model=ST96812AS, FwRev=7.24, SerialNo=3PJ1GCKE
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=off
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=117231408
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7

 * signifies the current active mode

root@debian:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   746 MB in  2.00 seconds = 372.90 MB/sec
 Timing buffered disk reads: 120 MB in  3.03 seconds =  39.56 MB/sec
.pre

^ GPIO

* https://github.com/gootoomoon/WiringCB-python

^ Camera

[OV7670] is supported http://linux-sunxi.org/CSI

* https://groups.google.com/forum/#!msg/linux-sunxi/DYWwfUFgVlw/_7A5APHyl7UJ
* https://groups.google.com/forum/#!msg/cubieboard/SWzC9qvpVL8/9cjQ_CPHQzUJ

^ hardware

* http://linux-sunxi.org/Cubieboard/ExpansionPorts
* https://linux-sunxi.org/A20/PIO

pinout: {image: gpio_defination_large.jpg}

https://www.olimex.com/wiki/How_to_add_pwm

.pre
cat /sys/class/pwm-sunxi/pwm0/pin 
PB2

echo 10khz > /sys/class/pwm-sunxi/pwm0/period

echo 25 > /sys/class/pwm-sunxi/pwm0/duty_percent

echo 1 > /sys/class/pwm-sunxi/pwm0/run
.pre

^^ LEDs

.pre
dpavlin@cubieboard2:~$ grep . /sys/class/leds/*/trigger 
/sys/class/leds/blue:ph21:led2/trigger:none battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer [heartbeat] backlight cpu0 cpu1 default-on 
/sys/class/leds/green:ph20:led1/trigger:[none] battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer heartbeat backlight cpu0 cpu1 default-on 
.pre

^ forum

* ov7670 http://www.cubieforums.com/index.php/topic,3823.0.html
* LVDS http://www.cubieforums.com/index.php/topic,3908.0.html

^ ina219

^^ device tree

* https://github.com/dpavlin/sunxi-DT-overlays/blob/cubieboard2/examples/i2c-ina219.dts

.pre
dpavlin@cubieboard2:~$ sensors
ina219-i2c-1-40
Adapter: mv64xxx_i2c adapter
in0:          +0.04 V  
in1:          +4.64 V  
power1:       66.88 W  
curr1:       +13.64 A  

iio_hwmon-isa-0000
Adapter: ISA adapter
temp1:        +33.6�C  

root@cubieboard2:~# dmesg | grep ina | tail -1
[ 6597.685287] ina2xx 1-0040: power monitor ina219 (Rshunt = 100 uOhm)

# hum, it should be 10uA, so I changed that in device tree

dpavlin@cubieboard2:~$ dmesg | grep ina219
[   11.594536] ina2xx 1-0040: power monitor ina219 (Rshunt = 10 uOhm)
dpavlin@cubieboard2:~$ sensors
ina219-i2c-1-40
Adapter: mv64xxx_i2c adapter
in0:          +0.02 V  
in1:          +4.75 V  
power1:       85.00 W  
curr1:       +17.97 A  

iio_hwmon-isa-0000
Adapter: ISA adapter
temp1:        +32.5�C  

# still wrong current!

.pre

^^ user-land C

User-land implementation which works: https://github.com/ZigFisher/Glutinium/blob/master/i2c-telemetry/src/ina219.c

modified a little to provide full timestamp and fflush: {file: ina219.c}

.pre
dpavlin@cubieboard2:~$ ./ina219 -b 1 -i 1
2017-10-23T12:40:24 4744mV  262.2mA
2017-10-23T12:40:26 4756mV  249.1mA
2017-10-23T12:40:27 4776mV  223.0mA
2017-10-23T12:40:28 4772mV  223.8mA
2017-10-23T12:40:29 4760mV  224.0mA
2017-10-23T12:40:30 4768mV  223.0mA
2017-10-23T12:40:31 4772mV  223.1mA
2017-10-23T12:40:32 4748mV  224.6mA
2017-10-23T12:40:33 4776mV  223.1mA
2017-10-23T12:40:34 4768mV  223.5mA
.pre

^ SPI flash

^^ flashrom

.pre
dpavlin@cubieboard:~$ sudo grep spidev /boot/armbianEnv.txt
overlays=pwm nand uart3 uart4 spi-spidev
#overlays=spi-spidev
param_spidev_spi_bus=0


dpavlin@cubieboard:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0
flashrom v0.9.9-2-g51e4303 on Linux 4.14.47-sunxi (armv7l)
flashrom is free software, get the source code at https://flashrom.org

Calibrating delay loop... OK.
Found GigaDevice flash chip "GD25Q80(B)" (1024 kB, SPI) on linux_spi.
No operations were specified.

root@cubieboard:/home/dpavlin# time flashrom -p linux_spi:dev=/dev/spidev0.0 -r /dev/null
flashrom v0.9.9-2-g51e4303 on Linux 4.14.47-sunxi (armv7l)
flashrom is free software, get the source code at https://flashrom.org

Calibrating delay loop... OK.
Found GigaDevice flash chip "GD25Q80(B)" (1024 kB, SPI) on linux_spi.
Reading flash... done.

real    0m11.210s
user    0m0.796s
sys     0m0.381s

.pre

^^ build u-boot with SPI support

http://linux-sunxi.org/Bootable_SPI_flash

.pre
git clone -b sunxi-spi https://github.com/StephanvanSchaik/u-boot

dpavlin@armbian:~/u-boot$ git diff
diff --git a/configs/Cubieboard_defconfig b/configs/Cubieboard_defconfig
index 0389d4c..cbafac9 100644
--- a/configs/Cubieboard_defconfig
+++ b/configs/Cubieboard_defconfig
@@ -16,3 +16,13 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_USB_EHCI_HCD=y
+
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_DM_SPI=y
+CONFIG_SUNXI_SPI=y
+
dpavlin@armbian:~/u-boot$ make Cubieboard_defconfig



.pre

This doesn't actually work for me (since it's missing device tree overlays), but rebasing to current u-boot master doesn't
produce code which compiles.

https://forum.armbian.com/topic/3252-opi-zero-boot-with-spi/
Welcome to my new unsorted stuff site. If you are here to "learn about rot13"<http://en.wikipedia.org/wiki/ROT13> this might not be the right place.

If you are, however looking latest and/or unsorted snippets which didn't made to "my homepage"<http://www.rot13.org/~dpavlin/> or "blog"<http://blog.rot13.org/> you might be on right place.

Recent changes are best way to get a hang of what's going on.

| {search: category: projects} | {search: category: howto} |

{fetchrss: http://blog.rot13.org/index.xml}
^ PICKit 2

^^ pk2cmd

.pre
pi@rpi2 ~ $ git clone https://github.com/psmay/pk2cmd
pi@rpi2 ~ $ cd pk2cmd/pk2cmd
pi@rpi2 ~/pk2cmd/pk2cmd $ make linux

pi@rpi2 ~/pk2cmd/pk2cmd $ ./pk2cmd -P
Auto-Detect: Found part PIC16F684.

# power on target from pickit 2
pi@rpi2 ~/pk2cmd/pk2cmd $ ./pk2cmd -PPIC16F684 -T
.pre

^^ serial

https://github.com/majenkotech/pk2serial
Original from CCC, let's try to compile with sdcc for it.

https://events.ccc.de/camp/2007/Fahrplan/attachments/1337-Sputnik%20Slides


The OpenBeacon Tag consists of

    nRF24L01 2.4GHz transceiver (1/2MBps)
    PIC16F684 PIC14 microcontroller

{toc: }

^ Schematics

{file: OpenBeacon.pdf}


^ pinout

(same as pickit)

1 VPP/RA3 (Square pin)
2 VDD
3 GND
4 ICSPDAT/RA0
5 ICSPCLK/RA1 (also connected to touch sensor)
6 PGM (seems to be unconnected)

^ [PicKit] 2

.pre
pi@rpi2 ~ $ git clone https://github.com/psmay/pk2cmd
pi@rpi2 ~ $ cd pk2cmd/pk2cmd
pi@rpi2 ~/pk2cmd/pk2cmd $ make linux

pi@rpi2 ~/pk2cmd/pk2cmd $ ./pk2cmd -P
Auto-Detect: Found part PIC16F684.

# power on target of pickit 2 which is sputlink tag
pi@rpi2 ~/pk2cmd/pk2cmd $ ./pk2cmd -PPIC16F684 -T

.pre

^ Source

.pre
dpavlin@klin:/rest/cvs$ git clone https://github.com/meriac/openbeacon

.pre

^ archival links

* https://web.archive.org/web/20111119165129/http://www.openbeacon.org/dl/23C3/OpenBeacon.pdf
* http://sdr.osmocom.org/trac/wiki/rtl-sdr
* http://rtl-entropy.org/

{toc: }

^ calibration

https://github.com/steve-m/kalibrate-rtl

.pre
dpavlin@nuc:/nuc/kalibrate-rtl$ ./src/kal -s GSM900
Found 1 device(s):
  0:  Terratec T Stick PLUS

Using device 0: Terratec T Stick PLUS
Found Elonics E4000 tuner
Exact sample rate is: 270833.002142 Hz
kal: Scanning for GSM-900 base stations.
GSM-900:
        chan: 53 (945.6MHz - 14.311kHz) power: 873627.18
        chan: 61 (947.2MHz - 14.203kHz) power: 5086424.19
        chan: 69 (948.8MHz - 14.217kHz) power: 925674.55
        chan: 82 (951.4MHz - 14.368kHz) power: 1267065.47
        chan: 89 (952.8MHz - 14.430kHz) power: 914349.18
        chan: 99 (954.8MHz - 14.352kHz) power: 902132.81
        chan: 105 (956.0MHz - 14.380kHz)        power: 990434.19
        chan: 108 (956.6MHz - 14.350kHz)        power: 2682914.97

dpavlin@nuc:/nuc/kalibrate-rtl$ ./src/kal -c 61
Found 1 device(s):
  0:  Terratec T Stick PLUS

Using device 0: Terratec T Stick PLUS
Found Elonics E4000 tuner
Exact sample rate is: 270833.002142 Hz
kal: Calculating clock frequency offset.
Using GSM-900 channel 61 (947.2MHz)
average         [min, max]      (range, stddev)
- 14.238kHz             [-14257, -14220]        (37, 8.682419)
overruns: 0
not found: 0
average absolute error: 15.032 ppm



dpavlin@nuc:/nuc/kalibrate-rtl$ ./src/kal -c 61
Found 2 device(s):
  0:  Generic RTL2832U OEM
  1:  Terratec T Stick PLUS

Using device 0: Generic RTL2832U OEM
Found Fitipower FC0012 tuner
Exact sample rate is: 270833.002142 Hz
kal: Calculating clock frequency offset.
Using GSM-900 channel 61 (947.2MHz)
average         [min, max]      (range, stddev)
- 36.021kHz             [-36032, -36011]        (21, 5.899949)
overruns: 0
not found: 0
average absolute error: 38.028 ppm


.pre

^ DVB-T Digital TV Receiver USB Dongle w/ FM / Remote Control / Antenna - Black

http://dx.com/p/dvb-t-digital-tv-receiver-usb-dongle-w-fm-remote-control-antenna-black-149928

.pre
dpavlin@blue:~$ lsusb | grep DVB
Bus 001 Device 007: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T

dpavlin@blue:~$ sudo rtl_test -t
[sudo] password for dpavlin: 
Found 1 device(s):
  0:  ezcap USB 2.0 DVB-T/DAB/FM dongle

Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
No E4000 tuner found, aborting.


dpavlin@blue:/blue/rtl-sdr/rtl-sdr/build$ sudo rtl_tcp 
Found 1 device(s).
Found Rafael Micro R820T tuner
Using ezcap USB 2.0 DVB-T/DAB/FM dongle
Tuned to 100000000 Hz.
listening...
Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).
.pre

^ E4000+2832U USB DVB-T TV Receiver Stick

http://dx.com/p/e4000-2832u-usb-dvb-t-tv-receiver-stick-white-black-172105

.pre
dpavlin@blue:~$ rtl_test -t
Found 1 device(s):
  0:  Terratec T Stick PLUS

Using device 0: Terratec T Stick PLUS
Found Elonics E4000 tuner
Supported gain values (14): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 
Benchmarking E4000 PLL...
[E4K] PLL not locked for 52000000 Hz!
[E4K] PLL not locked for 2227000000 Hz!
[E4K] PLL not locked for 1114000000 Hz!
[E4K] PLL not locked for 1274000000 Hz!
E4K range: 53 to 2226 MHz
E4K L-band gap: 1114 to 1274 MHz
.pre

^ Hama 53176

* FC0013 tuner

{image: Hama1.jpg}

{image: hama2.jpg}

{image: hama3.jpg}

^ TV LV5TDLX

* FC0012 tuner

{image: LV51.jpg}
{image: LV52.jpg}
{image: LV53.jpg}
{toc: }

{image: ch341a_miniprogrammer.jpg}

This is 5V device without modification! It works for me(tm) but you have been warned

http://www.eevblog.com/forum/repair/ch341a-serial-memory-programmer-power-supply-fix/

Just lift pin 28 and put some tape under it to prevent any short circuit. Then solder one wire from this pin to pin 2 of AMS1117 and also to C4. The side of the C4 to connect is the one connected to CH341A pin 9.

{file: CHM341A-3V3-fix.jpg}

^ jumper on pins

1-2 SPI flash programmer mode
2-3 TTL serial mode

supported out-of-box by flashrom, probably better option, but anyway:

https://github.com/setarcos/ch341prog

.pre
dpavlin@nuc:/nuc/ch341a$ git clone https://github.com/setarcos/ch341prog
Cloning into 'ch341prog'...
remote: Counting objects: 104, done.
remote: Total 104 (delta 0), reused 0 (delta 0), pack-reused 104
Receiving objects: 100% (104/104), 34.79 KiB | 0 bytes/s, done.
Resolving deltas: 100% (61/61), done.
Checking connectivity... done.
dpavlin@nuc:/nuc/ch341a$ cd ch341prog/
dpavlin@nuc:/nuc/ch341a/ch341prog$ make
gcc -std=gnu99 -Wall ch341a.c main.c -o ch341prog  -lusb-1.0
dpavlin@nuc:/nuc/ch341a/ch341prog$ ./ch341prog 

Usage:
 -h, --help             display this message
 -i, --info             read the chip ID info
 -e, --erase            erase the entire chip
 -l, --length <bytes>   manually set length
 -w, --write <filename> write chip with data from filename
 -r, --read <filename>  read chip and save data to filename
 -t, --turbo            increase the i2c bus speed (-tt to use much faster speed)
 -d, --double           double the spi bus speed
.pre

^ I2C in userspace

https://sourceforge.net/projects/ch341eepromtool/

.pre
dpavlin@nuc:/nuc/ch341a/ch341eepromtool_0.5$ gcc -o ch341eeprom ch341eeprom.c ch341funcs.c -lusb-1.0
dpavlin@nuc:/nuc/ch341a/ch341eepromtool_0.5$ 
dpavlin@nuc:/nuc/ch341a/ch341eepromtool_0.5$ ./ch341eeprom 
ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC
Version 0.5 copyright (c) 2011  asbokid <ballymunboy@gmail.com>

This program comes with asbolutely no warranty; This is free software,
and you are welcome to redistribute it under certain conditions:
GNU GPL v3 License: http://www.gnu.org/licenses/gpl.html

Usage:
 -h, --help             display this text
 -v, --verbose          verbose output
 -d, --debug            debug output
 -s, --size             size of EEPROM {24c32|24c64}
 -e, --erase            erase EEPROM (fill with 0xff)
 -w, --write <filename> write EEPROM with image from filename
 -r, --read  <filename> read EEPROM and save image to filename

Example:  ch341eeprom -v -s 24c64 -w bootrom.bin
.pre

^ flashrom SPI

Not needed anymore, included in mainline flashrom

.pre
git clone https://github.com/urjaman/flashrom/
git checkout -b origin/ch341a origin/ch341a

dpavlin@nuc:/nuc/flashrom$ sudo apt-get install pciutils-dev


.pre

^ linux kernel spi module

.pre
dpavlin@nuc:/nuc$ git clone https://github.com/gschorcht/spi-ch341-usb.git
Cloning into 'spi-ch341-usb'...
remote: Counting objects: 63, done.
remote: Total 63 (delta 0), reused 0 (delta 0), pack-reused 63
Unpacking objects: 100% (63/63), done.
dpavlin@nuc:/nuc$ cd spi-ch341-usb
dpavlin@nuc:/nuc/spi-ch341-usb$ make
make -C /usr/src/linux-headers-4.14.0-3-amd64/ M=/nuc/spi-ch341-usb  modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.0-3-amd64'
  CC [M]  /nuc/spi-ch341-usb/spi-ch341-usb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /nuc/spi-ch341-usb/spi-ch341-usb.mod.o
  LD [M]  /nuc/spi-ch341-usb/spi-ch341-usb.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.14.0-3-amd64'
dpavlin@nuc:/nuc/spi-ch341-usb$ 
dpavlin@nuc:/nuc/spi-ch341-usb$ sudo make install
[sudo] password for dpavlin: 

dpavlin@nuc:/nuc/spi-ch341-usb$ sudo modprobe spi-ch341-usb

[525021.048281] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output cs0 SPI slave with cs=0
[525021.048285] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output cs1 SPI slave with cs=1
[525021.048287] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output cs2 SPI slave with cs=2
[525021.048290] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio4 gpio=0 irq=0 (hwirq)
[525021.048292] spi-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio5 gpio=1 irq=1 
[525021.048296] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI master connected to SPI bus 0
[525021.048426] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI device /dev/spidev0.0 created
[525021.048516] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI device /dev/spidev0.1 created
[525021.048596] spi-ch341-usb 2-2.1.4:1.0: ch341_spi_probe: SPI device /dev/spidev0.2 created
[525021.049147] spi-ch341-usb 2-2.1.4:1.0: ch341_usb_probe: connected
[525021.049194] usbcore: registered new interface driver spi-ch341-usb


.pre

^ linux kernel i2c module

* https://github.com/gschorcht/i2c-ch341-usb

.pre
root@nuc:/nuc# git clone https://github.com/gschorcht/i2c-ch341-usb.git
Cloning into 'i2c-ch341-usb'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
root@nuc:/nuc# cd i2c-ch341-usb
root@nuc:/nuc/i2c-ch341-usb# make
make -C /usr/src/linux-headers-4.14.0-3-amd64/ M=/nuc/i2c-ch341-usb  modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.0-3-amd64'
  CC [M]  /nuc/i2c-ch341-usb/i2c-ch341-usb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /nuc/i2c-ch341-usb/i2c-ch341-usb.mod.o
  LD [M]  /nuc/i2c-ch341-usb/i2c-ch341-usb.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.14.0-3-amd64'
root@nuc:/nuc/i2c-ch341-usb# 
root@nuc:/nuc/i2c-ch341-usb# sudo make install

root@nuc:/nuc/i2c-ch341-usb# modprobe i2c-ch341-usb

[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio0 gpio=0 irq=0 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio1 gpio=1 irq=1 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio2 gpio=2 irq=2 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: output gpio3 gpio=3 irq=3 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio4 gpio=4 irq=4 (hwirq)
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio5 gpio=5 irq=5 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio6 gpio=6 irq=6 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_cfg_probe: input  gpio7 gpio=7 irq=7 
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_i2c_probe: created i2c device /dev/i2c-8
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_i2c_set_speed: Change i2c bus speed to 100 kbps
[Wed Feb  7 16:37:00 2018] i2c-ch341-usb 2-2.1.4:1.0: ch341_usb_probe: connected
[Wed Feb  7 16:37:00 2018] usbcore: registered new interface driver i2c-ch341-usb





.pre

^ schematics and info

* http://onetransistor.blogspot.hr/2017/08/ch341a-mini-programmer-schematic.html
* http://www.zoobab.com/ch341-usb-spi-i2c-uart-isp-dongle

I added soic 8 pinout over zif socket, because position of pin 1 is not obvious (or clearly marked anywhere on top). I suggest that you fix that with silver sharpy.

{image: ch341a_miniprogrammer_schematic.png}
* https://osmocom.org/projects/osmo-fl2k/wiki/Osmo-fl2k

see also [rtl-sdr] for receiver part

.pre
dpavlin@nuc:~$ lsusb -d 1d5c:2000 
Bus 003 Device 007: ID 1d5c:2000  

dpavlin@nuc:~$ sudo fl2k_test -s 162e6
[sudo] password for dpavlin: 
Using 6 zero-copy buffers
libusb: error [op_dev_mem_alloc] alloc dev mem failed errno 12
Failed to allocate zerocopy buffer for transfer 4
Reporting PPM error measurement every 10 seconds...
Press ^C after a few minutes.
real sample rate: 144376742 current PPM: -108786 cumulative PPM: -108786
real sample rate: 144270861 current PPM: -109439 cumulative PPM: -109125
real sample rate: 144227755 current PPM: -109705 cumulative PPM: -109323
^CSignal caught, exiting!


.pre
{toc}

^ pinout

{image: nRF24L01_pinout.jpg}

It seems that v2.0 devies are 32k while Internet wants us to beleve that they are 16k (v1.0 maybe?)

^ original firmware output

.pre
[11985.181504] usb 2-2.1: new full-speed USB device number 7 using xhci_hcd
[11985.285687] usb 2-2.1: New USB device found, idVendor=1915, idProduct=002b
[11985.285690] usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[11985.285692] usb 2-2.1: Product: Nordic Semiconductor nRFready Basic Remote Dongle
[11985.285694] usb 2-2.1: Manufacturer: Nordic Semiconductor
[11985.285695] usb 2-2.1: SerialNumber: \xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf\xffffffef\xffffffbf\xffffffbf
[11985.301719] input: Nordic Semiconductor Nordic Semiconductor nRFready Basic Remote Dongle as /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2.1/2-2.1:1.0/0003:1915:002B.0005/input/input11
[11985.361937] hid-generic 0003:1915:002B.0005: input,hiddev0,hidraw2: USB HID v1.11 Keyboard [Nordic Semiconductor Nordic Semiconductor nRFready Basic Remote Dongle] on usb-0000:00:14.0-2.1/input0
.pre

^ mouse jack tools

https://github.com/BastilleResearch/mousejack

^^ find device address

.pre
dpavlin@nuc:/nuc/nRF24L01/mousejack/nrf-research-firmware/tools$ ./nrf24-scanner.py 
[2017-01-07 13:50:59.174]  12   0  65:6F:91:A9:07  
[2017-01-07 13:51:07.012]   8  10  65:6F:91:A9:07  00:C2:00:00:F8:FF:FE:00:00:49
[2017-01-07 13:51:15.216]   8  10  65:6F:91:A9:07  00:C2:00:00:17:D0:FF:00:00:58
[2017-01-07 13:51:15.231]   8   0  65:6F:91:A9:07  
[2017-01-07 13:51:15.698]  12   0  65:6F:91:A9:07  
[2017-01-07 13:51:23.456]   8  10  65:6F:91:A9:07  00:C2:00:00:EB:BF:FF:00:00:95
[2017-01-07 13:51:23.503]   8  10  65:6F:91:A9:07  00:C2:00:00:FF:0F:FF:00:00:31
[2017-01-07 13:51:23.509]   8   0  65:6F:91:A9:07  
[2017-01-07 13:51:23.840]  12   0  65:6F:91:A9:07  
.pre

^^ sniff

.pre
dpavlin@nuc:/nuc/nRF24L01/mousejack/nrf-research-firmware/tools$ ./nrf24-sniffer.py -c 8 12 -a 65:6F:91:A9:07
[2017-01-07 13:53:34.922]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.930]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.938]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.946]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.962]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.970]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.979]   8  22  65:6F:91:A9:07  00:D3:44:0F:5C:E6:CD:54:B5:71:8C:F9:99:33:00:00:00:00:00:00:00:00
[2017-01-07 13:53:34.986]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:34.994]   8  10  65:6F:91:A9:07  00:4F:00:01:18:00:00:00:00:98
[2017-01-07 13:53:35.125]   8   5  65:6F:91:A9:07  00:40:01:18:A7
[2017-01-07 13:53:35.278]   8  22  65:6F:91:A9:07  00:D3:B0:F4:B3:27:E3:BE:34:72:8C:F9:99:34:00:00:00:00:00:00:00:16
[2017-01-07 13:53:35.285]   8   5  65:6F:91:A9:07  00:40:00:08:B8
[2017-01-07 13:53:35.301]   8   5  65:6F:91:A9:07  00:40:00:08:B8
.pre


^ flashing

https://github.com/BastilleResearch/mousejack/issues/6
https://wiki.bitcraze.io/projects:crazyradio:spi_programming


^^ bus pirate

https://github.com/koolatron/buspirate_nrf24lu1p

| Bus Pirate || nRF24LU1+ |
| 3V3  | -> | VDD  |
| AUX  | -> | PROG |
| SCK  | -> | SCK  |
| MOSI | -> | MOSI |
| MISO | -> | MISO |
| CS   | -> | CSN  |
| GND  | -> | GND  |

.pre
dpavlin@nuc:/nuc/nRF24L01/buspirate_nrf24lu1p$ ./flasher.pl -device /dev/ttyUSB0 -input ../mousejack/nrf-research-firmware/bin/dongle.bin 

.pre

^ bootloader

^^ 512 byte replacement

https://github.com/ahtn/nrf24lu1p-512-bootloader

^^ original bootloader

https://github.com/al177/buspirate_nrf24lu1p

^ Logitech C-U0007

Version with fixed ctrl+c exit bug: https://github.com/cl0udz/mousejack

.pre
dpavlin@x230:/x230/mousejack$ git remote -v
cl0udz  https://github.com/cl0udz/mousejack (fetch)
cl0udz  https://github.com/cl0udz/mousejack (push)

dpavlin@x230:/x230/mousejack/nrf-research-firmware$ make logitech_install

[Fri Apr 27 22:10:16 2018] usb 1-1.2: new full-speed USB device number 23 using ehci-pci
[Fri Apr 27 22:10:16 2018] usb 1-1.2: New USB device found, idVendor=1915, idProduct=0102
[Fri Apr 27 22:10:16 2018] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Fri Apr 27 22:10:16 2018] usb 1-1.2: Product: Research Firmware
[Fri Apr 27 22:10:16 2018] usb 1-1.2: Manufacturer: RFStorm

dpavlin@x230:/x230/mousejack/nrf-research-firmware$ ./tools/nrf24-scanner.py 
[2018-04-29 14:23:51.370]   5  22  65:6F:91:A9:07  00:D3:D5:D7:4F:76:ED:63:55:70:EC:77:61:0F:00:00:00:00:00:00:00:D4
[2018-04-29 14:23:51.786]   9   5  65:6F:91:A9:07  00:40:00:08:B8




.pre
* http://www.seeedstudio.com/wiki/FST-01
* https://gitorious.org/gnuk
* http://www.fsij.org/doc-gnuk/index.html
* build one from ST-Link clone https://blog.danman.eu/2-usb-crypto-token-for-use-with-gpg-and-ssh/

^ update vid and pid in compiled binary

since version 1.2.8 you need to insert vid and pid into the binary by running

.pre
make build/gnuk-vidpid.elf
.pre

and than flash the resulting gnuk-vidpid.bin binary into your FST-01

^ SWD flashing using ST Link v2

.pre
usb 1-1.6.4: new full-speed USB device number 16 using ehci-pci
usb 1-1.6.4: New USB device found, idVendor=0483, idProduct=3748
usb 1-1.6.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.6.4: Product: STM32 STLink
usb 1-1.6.4: Manufacturer: STMicroelectronics
usb 1-1.6.4: SerialNumber: Qÿl^FH<85>PH'Q^C<87>
.pre

* http://www.gniibe.org/memo/development/fst-01/dongle/fst-01-swd-connection
* http://no-passwd.net/askbot/question/48/how-can-i-re-flash-fst-01/

Problem:

.pre
dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk/tool$ ./stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
CORE: 0de01477, CHIP_ID: 00000000
Flash ROM read protection: off
Option bytes: 00000000
Core does not halt, try API V2 halt.
ValueError('Status of core is not halt.', 128)
.pre

after several re-runs:

.pre
dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk/tool$ ./stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
CORE: 1ba01477, CHIP_ID: a0036410
Flash ROM read protection: off
Option bytes: a0036410
Core does not halt, try API V2 halt.
ValueError('Status of core is not halt.', 128)
.pre

after a bit of fiddling with cables (it's always cables, right?)

Lovro contributed that if you are getting continous output like this

.pre
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
Core does not halt, try API V2 halt.
ValueError('Status of core is not halt.', 128)
.pre

then run this while holding reset active (hold tweezers on both side of C3)
that should hand the uC in a mode that will enable stlinkv2.py script to turn off the flash rom protection and erase the flash while doing that

.pre
dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: ON
Option bytes: 03fffffe
The MCU is now stopped.
SUCCESS

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -u
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
Status is 0081
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: ON
Option bytes: 03fffffe
Flash ROM read protection disabled.  Reset the board, now.
SUCCESS

# plugin, plugout st-link/v2

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0100 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: off
Option bytes: ffff5aa5
Flash ROM blank check: True
SUCCESS

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -b ../binaries/gnuk/gnuk.bin 
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0001 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: off
Option bytes: ffff5aa5
Flash ROM blank check: True
SPI Flash ROM ID: bf254a
WRITE
VERIFY
PROTECT
Flash ROM read protection enabled.  Reset the board to enable protection.
SUCCESS

# power cycle

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0100 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: ON
Option bytes: 03fffffe
The MCU is now stopped.
SUCCESS
.pre

plugin just FST-01:

.pre
[ 9890.019368] usb 1-1.6.4: New USB device found, idVendor=234b, idProduct=0000
[ 9890.019372] usb 1-1.6.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9890.019374] usb 1-1.6.4: Product: Gnuk Token
[ 9890.019375] usb 1-1.6.4: Manufacturer: Free Software Initiative of Japan
[ 9890.019377] usb 1-1.6.4: SerialNumber: FSIJ-1.0.4-50FF7006
.pre
BeagleBone Black

{toc}

https://elinux.org/Beagleboard:BeagleBoneBlack

^ info

.pre
root@beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
root@beaglebone:~# cat /proc/cpuinfo 
processor       : 0
model name      : ARMv7 Processor rev 2 (v7l)
BogoMIPS        : 297.40
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc08
CPU revision    : 2

Hardware        : Generic AM33XX (Flattened Device Tree)
Revision        : 0000
Serial          : 0000000000000000
root@beaglebone:~# cat /etc/issue
Angstrom v2012.12 - Kernel \r
.pre

^ serial

Board	Cable
Pin 1 (GND)	Black (GND)
Pin 4 (RX)	Green (TX)
Pin 5 (TX)	White (RX)

^ update board

.pre
dpavlin@nuc:/tmp$ xzcat bone-debian-9.3-iot-armhf-2018-01-28-4gb.img.xz | sudo dd of=/dev/sdc bs=1M
.pre

Insert SD card, press S2 USER/BOOT button to boot from SD card

https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Flashing_eMMC

.pre
root@beaglebone:~# uname -a
Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018 armv7l GNU/Linux
root@beaglebone:~# cat /etc/issue
Debian GNU/Linux 9 \n \l

BeagleBoard.org Debian Image 2018-01-28

.pre

^ usb network

.pre
root@nuc:/home/dpavlin# ip link

8: enxd05fb8d1023b: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether d0:5f:b8:d1:02:3b brd ff:ff:ff:ff:ff:ff
9: enxd05fb8d1023e: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether d0:5f:b8:d1:02:3e brd ff:ff:ff:ff:ff:ff

root@beaglebone:~# ip addr
5: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d0:5f:b8:d1:02:3c brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.2/30 brd 192.168.7.3 scope global usb0
       valid_lft forever preferred_lft forever
    inet6 fe80::d25f:b8ff:fed1:23c/64 scope link 
       valid_lft forever preferred_lft forever
6: usb1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d0:5f:b8:d1:02:3f brd ff:ff:ff:ff:ff:ff
    inet 192.168.6.2/30 brd 192.168.6.3 scope global usb1
       valid_lft forever preferred_lft forever
    inet6 fe80::d25f:b8ff:fed1:23f/64 scope link 
       valid_lft forever preferred_lft forever

# matchs IP addresses to find out which interface on bbb is which on nuc (mac on nuc is one less than bbb), so

root@nuc:/home/dpavlin# ifconfig enxd05fb8d1023b 192.168.7.1
root@nuc:/home/dpavlin# ping -c 1 192.168.7.2
PING 192.168.7.2 (192.168.7.2) 56(84) bytes of data.
64 bytes from 192.168.7.2: icmp_seq=1 ttl=64 time=0.817 ms

--- 192.168.7.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.817/0.817/0.817/0.000 ms

# nat bbb

root@nuc:/home/dpavlin# iptables -t nat -A POSTROUTING -s 192.168.7.0/30 -o eth0 -j MASQUERADE

dpavlin@nuc:~$ ssh debian@192.168.7.2
debian@192.168.7.2's password: 
Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018 armv7l

root@beaglebone:/home/debian# ip route add default via 192.168.7.1
root@beaglebone:/home/debian# ip route add default via 192.168.7.1
root@beaglebone:/home/debian# cat /etc/resolv.conf 
nameserver 8.8.8.8
root@beaglebone:/home/debian# ping -c 1 www.google.com
PING www.google.com (172.217.21.100) 56(84) bytes of data.
64 bytes from fra07s32-in-f100.1e100.net (172.217.21.100): icmp_seq=1 ttl=51 time=30.4 ms

--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 30.460/30.460/30.460/0.000 ms

.pre


^ PRU

http://ianrrees.github.io/2016/11/20/getting-started-with-beaglebone-pru-programming-the-new-way.html
This page will try to document my experiment to run mainline kernel on OMAP

{toc}

* https://www.xda-developers.com/patch-this-barnes-and-noble-nook-tablet-hardware-protection-compromised/

^ uart

{image: nook-color-uart.jpg}
{toc}

^ STM8S003F3

{image: STM8S003F3P6.jpg}

* STM8S003F3P6
* 3.3V
* LED on PD3

* http://www.cnx-software.com/2015/04/13/how-to-program-stm8s-1-board-in-linux/

.pre
dpavlin@x200:/rest/cvs/stm8flash$ git remote -v
origin  https://github.com/vdudouyt/stm8flash (fetch)
origin  https://github.com/vdudouyt/stm8flash (push)

dpavlin@x200:/rest/cvs$ git clone https://github.com/vdudouyt/sdcc-examples-stm8.git
dpavlin@x200:/rest/cvs$ cd sdcc-examples-stm8/
dpavlin@x200:/rest/cvs/sdcc-examples-stm8$ make
dpavlin@x200:/rest/cvs/sdcc-examples-stm8$ git diff
diff --git a/Makefile b/Makefile
index bec46da..e23d5e3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 SDCC=sdcc
 SDLD=sdld
-OBJECTS=blinky.ihx uart.ihx sp_test.ihx
+OBJECTS=blinky.ihx uart.ihx
 
 .PHONY: all clean flash
 
dpavlin@x200:/rest/cvs/sdcc-examples-stm8$ make
sdcc -lstm8 -mstm8 --out-fmt-ihx   blinky.c
sdcc -lstm8 -mstm8 --out-fmt-ihx   uart.c

dpavlin@x200:/rest/cvs/stm8flash$ ./stm8flash -c stlinkv2 -p stm8s003 -w ../sdcc-examples-stm8/blinky.ihx 
Determine FLASH area
Writing Intel hex file 191 bytes at 0x8000... OK
Bytes written: 191



.pre

* http://stm8sdiscovery.nano-age.co.uk/adventures-in-stm8-assembler



^ STM8S103F3

* STM8S103F3P6
* 3.3V
* LED on B5


^ SWIM programming

* http://www2.st.com/content/ccc/resource/technical/document/user_manual/ca/89/41/4e/72/31/49/f4/CD00173911.pdf/files/CD00173911.pdf/jcr:content/translations/en.CD00173911.pdf
* https://github.com/cole3/STM8_SWIM
* https://github.com/gicking/STM8_serial_flasher

* https://github.com/gicking/stm8gal
{toc: }

^ links

* http://www.esp8266.com/
* https://github.com/esp8266/esp8266-wiki/wiki
* http://www.electrodragon.com/w/Wi07c
* https://nurdspace.nl/ESP8266

* Documentation, tools, firmwares https://onedrive.live.com/?cid=C4DDF72E6EEA3826&id=C4DDF72E6EEA3826%21631

* https://github.com/esp8266/arduino
* https://github.com/igrr/esptool-ck (with reset support)

* http://tim.jagenberg.info/2015/01/18/low-power-esp8266/

{image: module_v2.png}

* all IO is 3.3V (3.6V max)
* CH_PD i chip-enable and has to be connected to VCC (3.3V)
* RST, GPIO0, GPIO2 should be pulled up to VCC for normal operation (GPIO0 at minumum!)
* GPIO0 pull to ground for firmware update
* make sure that 3.3V VCC power supply can support 300-400mA or there *WILL* be problems!

^ serial port

baud rate 115200

.pre
AT+GMR
00160901

OK

AT+RST

OK

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 24444, room 16 
tail 12
chksum 0xe0
ho 0 tail 12 room 4
load 0x3ffe8000, len 3168, room 12 
tail 4
chksum 0x93
load 0x3ffe8c60, len 4956, room 4 
tail 8
chksum 0xbd
csum 0xbd

ready

.pre

^ ESP-201

http://www.banggood.com/ESP8266-ESP-201-Remote-Serial-Port-WIFI-Transceiver-Wireless-Module-p-964288.html

{image: ESP8266-ESP-201-pin-reference-v01.png}

from http://smarpl.com/content/esp8266-esp-201-module-first-impressions

* http://jas-hacks.blogspot.com/2015/04/iot-esp8266-esp-201-cc1110-xrf.html

> One quirk with the ESP-201 is that is IO15 has to be grounded for the device to function. To flash the device IO00 has to be grounded.

.pre
AT+RST

OK

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 212, room 16 
tail 4
chksum 0x5e
load 0x3ffe8000, len 788, room 4 
tail 0
chksum 0x1c
load 0x3ffe8314, len 72, room 8 
tail 0
chksum 0x55
csum 0x55
jump to user1

.pre

^ nodemcu

* https://github.com/nodemcu/nodemcu-firmware
* https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en

^^ esptool.py

.pre
dpavlin@x200:/rest/cvs/esptool$ git remote -v
origin  https://github.com/themadinventor/esptool (fetch)
origin  https://github.com/themadinventor/esptool (push)

dpavlin@x200:/rest/cvs/esptool$ ./esptool.py --port /dev/ttyUSB2 read_mac
Connecting...
MAC: 18:fe:34:a0:38:72
.pre

^^ flash firmware

.pre
dpavlin@blue:/opt/Espressif/esptool$ ./esptool.py read_mac
Connecting...
MAC: 18:fe:34:a0:38:72
dpavlin@blue:/opt/Espressif/esptool$ ./esptool.py --port /dev/ttyUSB0 write_flash 0x00000 ../nodemcu-firmware/pre_build/latest/nodemcu_latest.bin 
Connecting...
Erasing flash...
Writing at 0x00010800... (17 %) 
.pre

Get latest build from https://github.com/nodemcu/nodemcu-firmware/releases

.pre
dpavlin@x200:/rest/cvs/esptool$ ./esptool.py --port /dev/ttyUSB2 write_flash 0x00000 ./nodemcu_float_0.9.6-dev_20150406.bin

dpavlin@x200:/rest/cvs/esptool$ microcom -p /dev/ttyUSB2 -s 9600
connected to /dev/ttyUSB2
Escape character: Ctrl-\
Type the escape character followed by c to get to the menu or q to quit

> node.restart()

NodeMCU 0.9.6 build 20150406  powered by Lua 5.1.4
lua: cannot open init.lua
> 
.pre

^^ build from source

For latest features, you might want to rebuild software from github source

.pre
dpavlin@x200:/rest/cvs$ git clone https://github.com/pfalcon/esp-open-sdk.git

dpavlin@x200:/rest/cvs/esp-open-sdk$ export PATH=/rest/cvs/esp-open-sdk/xtensa-lx106-elf/bin:$PATH




git clone https://github.com/nodemcu/nodemcu-firmware.git
cd nodemcu-firmware

dpavlin@x200:/rest/cvs/nodemcu-firmware$ git checkout -b dev origin/dev
Branch dev set up to track remote branch dev from origin.
Switched to a new branch 'dev'


make

# check that device is in boot loader mode

dpavlin@x200:/rest/cvs/nodemcu-firmware$ ../esptool/esptool.py --port /dev/ttyUSB1 read_mac
Connecting...
MAC: 18:fe:34:99:f2:83

# flash new firmware

dpavlin@x200:/rest/cvs/nodemcu-firmware$ make flash ESPPORT=/dev/ttyUSB1
make -C ./app flash
make[1]: Entering directory '/rest/cvs/nodemcu-firmware/app'
../tools/esptool.py --port /dev/ttyUSB1 write_flash 0x00000 ../bin/0x00000.bin 0x10000 ../bin/0x10000.bin
Connecting...
Erasing flash...
Writing at 0x0000c500... (100 %)
Erasing flash...
Writing at 0x00068c00... (100 %)

Leaving...
make[1]: Leaving directory '/rest/cvs/nodemcu-firmware/app'

.pre

^^ A library for the Microchip MCP3021 A/D converter for use with the ESP8266.

https://github.com/AllAboutEE/ESP8266-MCP3021-Library

^ nodemcu-uploader

.pre
dpavlin@x200:/rest/cvs$ git clone https://github.com/kmpm/nodemcu-uploader
dpavlin@x200:/rest/cvs/nodemcu-uploader$ ./nodemcu-uploader.py --port /dev/ttyUSB2 --baud 9600 file list
Listing files
for key,value in pairs(file.list()) do print(key,value) end
> 
.pre

^ OpenOCD JTAG

https://github.com/projectgus/openocd

http://www.esp8266.com/viewtopic.php?f=9&t=1871#p11157

.pre
JTAG Signal -> ESP8266 GPIO Pin -> JTAG Pin (standard 20 pin connector)
TMS -> 14 -> 7
TDI -> 12 -> 5
TCK -> 13 -> 9
TDO -> 15 -> 13
RST -> RST -> 15
.pre

^ ESP8266 as wireless JTAG Programmer

https://github.com/emard/wifi_jtag

^ WIFI

* https://github.com/kripthor/WiFiBeaconJam

^ software serial

* C library https://github.com/plieningerweb/esp8266-software-uart
* Arduino https://github.com/plerup/espsoftwareserial

^ Sonoff

https://www.itead.cc/sonoff-wifi-wireless-switch.html
http://wiki.iteadstudio.com/Sonoff
https://github.com/arendst/Sonoff-MQTT-OTA

^^ pinout

My sonoff is early model, with just 4 pins (instead of 5)

1 - VCC
2 - RX
3 - TX
4 - GND




^ Programming

* https://tech.scargill.net/a-flashing-esp-chips-surprise/

use *dio* not *qio* to fix checksum errors

^^ CH340 USB to ESP8266 ESP-01 Wifi Module Adapter

It doesn't have GPIO0 connected to ground, so flashing doesn't work!

http://www.esp8266.com/wiki/doku.php?id=all-in-one-esp-usb-converter

^ ESP-01S DHT11 board

* https://github.com/IOT-MCU/ESP-01S-DHT11-v1.0

.pre
#define DHTTYPE DHT11
#define DHTPIN  2
DHT dht(DHTPIN, DHTTYPE, 11);

.pre
Installing Stratum II NTP server on [RaspberryPi] using [SiRF STAR III] gps

{toc}

^ Links

* http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html
* https://www.raspberrypi.org/forums/viewtopic.php?t=191050

^ Raspbian installation

.pre
root@ntpi:/home/pi# systemctl start ssh

root@ntpi:/home/pi# systemctl enable ssh

pi@ntpi:~ $ grep pps /boot/config.txt 
dtoverlay=pps-gpio,gpiopin=18

pi@ntpi:~ $ sudo apt-get install pps-tools

# reboot, after it:

pi@ntpi:~ $ dmesg | grep pps
[   30.331047] pps_core: LinuxPPS API ver. 1 registered
[   30.331066] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[   30.352868] pps pps0: new PPS source pps.-1
[   30.352966] pps pps0: Registered IRQ 178 as PPS source





root@ntpi:~# systemctl disable systemd-timesyncd
root@ntpi:~# systemctl stop systemd-timesyncd

pi@ntpi:~ $ hcitool scan
Scanning ...
        00:02:78:10:A2:32       SJ GPS

root@ntpi:/home/pi# ppstest /dev/pps0 
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
time_pps_fetch() error -1 (Connection timed out)
.pre

fail, gps module is powered off without bluetooth connection

.pre
root@ntpi:/home/pi# grep rfcomm /etc/rc.local 
rfcomm bind rfcomm0 00:02:78:10:A2:32



.pre


fix pps signal from this GPS and test again

.pre
root@ntpi:/home/pi# grep pps /boot/config.txt 
dtoverlay=pps-gpio,gpiopin=18,assert_falling_edge
root@ntpi:/home/pi# ppstest /dev/pps0 | head
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1516805100.156350675, sequence: 70193 - clear  0.000000000, sequence: 0
source 0 - assert 1516805100.176368675, sequence: 70195 - clear  0.000000000, sequence: 0
source 0 - assert 1516805100.196339675, sequence: 70196 - clear  0.000000000, sequence: 0
source 0 - assert 1516805100.216363675, sequence: 70198 - clear  0.000000000, sequence: 0
source 0 - assert 1516805100.236378675, sequence: 70200 - clear  0.000000000, sequence: 0
source 0 - assert 1516805100.256385675, sequence: 70202 - clear  0.000000000, sequence: 0
source 0 - assert 1516805100.276392675, sequence: 70204 - clear  0.000000000, sequence: 0


.pre

This doesn't work, we need one event per second

.pre
# make pin 18 pull-down
root@ntpi:/home/pi# raspi-gpio set 18 ip pd

root@ntpi:/home/pi# grep pps /boot/config.txt 
dtoverlay=pps-gpio,gpiopin=18,assert_falling_edge

root@ntpi:/home/pi# ppstest /dev/pps0 
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1517323262.001232132, sequence: 697469 - clear  0.000000000, sequence: 0
source 0 - assert 1517323263.001229640, sequence: 697470 - clear  0.000000000, sequence: 0
source 0 - assert 1517323264.001227157, sequence: 697471 - clear  0.000000000, sequence: 0
source 0 - assert 1517323265.001224685, sequence: 697472 - clear  0.000000000, sequence: 0
source 0 - assert 1517323265.788526615, sequence: 697474 - clear  0.000000000, sequence: 0
source 0 - assert 1517323266.001222221, sequence: 697475 - clear  0.000000000, sequence: 0

# works!



.pre

^ gpsd

.pre

pi@ntpi:~ $ sudo apt-get install gpsd


.pre

^ ntp server

.pre
root@ntpi:/home/pi# apt-get install ntp





.pre
^ connect

.pre
root@eeepy:~# hcitool scan
Scanning ...
        00:02:78:10:A2:32       SJ GPS
root@eeepy:~# sdptool add --channel=1 OPUSH
OBEX Object Push service registered
root@eeepy:~# rfcomm bind /dev/rfcomm0 00:02:78:10:A2:32
.pre

^ serial output

.pre
$ Version GSW3.1.1-SDK_3.1.00.07-C23P1.00 *2F
$ Version MADE BY NAVIUS 2006.4.5*7F
$ TOW:  0*66
$ WK:   1340*20
$ POS:  6378137 0 0*69
$ CLK:  96250*66
$ CHNL: 12*30
$ Baud rate: 9600  System clock: 1058.797MHz*36
$ Version GSW3.1.1-SDK_3.1.00.07-C23P1.00 *2F
$ Version MADE BY NAVIUS 2006.4.5*7F
$ TOW:  0*66
$ WK:   1340*20
$ POS:  6378137 0 0*69
$ CLK:  96250*66
$ CHNL: 12*30
$ Baud rate: 9600  System clock: 1058.797MHz*36
$GPGGA,235943.035,,,,,0,00,,,M,0.0,M,,0000*5A
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,20,00,000,,10,00,000,,25,00,000,,27,00,000,*79
$GPGSV,3,2,12,03,00,000,,31,00,000,,24,00,000,,15,00,000,*78
$GPGSV,3,3,12,16,00,000,,05,00,000,,01,00,000,,26,00,000,*7D
$GPRMC,235943.035,V,,,,,,,100905,,*2E
$GPGGA,235944.035,,,,,0,00,,,M,0.0,M,,0000*5D
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,20,00,000,,10,00,000,,25,00,000,,27,00,000,*79
$GPGSV,3,2,12,03,00,000,,31,00,000,,24,00,000,,15,00,000,*78
$GPGSV,3,3,12,16,00,000,,05,00,000,,01,00,000,,26,00,000,*7D
$GPRMC,235944.035,V,,,,,,,100905,,*29
$GPGGA,235945.035,,,,,0,00,,,M,0.0,M,,0000*5C
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
.pre

^ links

* http://gps.0xdc.ru/wiki/doku.php?id=sirfstar
* http://gps.0xdc.ru/static/sirf/device/Copilot_BTGPS3_D1598-S/
{toc: }

^ meanIT tablet Q70

7" IPS Quad Core

recovery: extdroid4.4.2_r2-a33-v2.0

^^ adb shell

.pre
dpavlin@siobhan:~$ adb shell
root@astar-ococci:/ #

root@astar-ococci:/ # cat /proc/cmdline                                        
console=ttyS0,115200 root=/dev/nandd init=/init loglevel=4 specialstr= partitions=bootloader@nanda:env@nandb:boot@nandc:system@nandd:data@nande:misc@nandf:recovery@nandg:cache@nandh:metadata@nandi:private@nandj:UDISK@nandk boot_type=0 config_size=39716

root@astar-ococci:/ # cat /proc/cpuinfo                                        
Processor       : ARMv7 Processor rev 5 (v7l)
processor       : 0
BogoMIPS        : 5714.28

processor       : 1
BogoMIPS        : 4800.00

processor       : 3
BogoMIPS        : 4800.00

Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

Hardware        : sun8i
Revision        : 0000
Serial          : 1a884915

.pre

^^ board

AL-AX3-751B-V1.0
2015.03.26

http://linux-sunxi.org/Aoson_M751s

https://github.com/Icenowy/linux-kernel-lichee-a33/tree/aoson-m751s

^ USB FEL

Vol+ to enter FEL mode

.pre
Bus 003 Device 004: ID 1f3a:efe8 Onda (unverified) V972 tablet in flashing mode

root@x230:~# sunxi-fel ver
AWUSBFEX soc=00001667(A33) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000

# read SID
root@x230:~# sunxi-fel readl 0x01c23800
0x0461872a

root@x230:~# sunxi-fel sid
0461872a:033c50c3:1a884915:00000000

.pre

^^ device info

* http://linux-sunxi.org/Retrieving_device_information

.pre
dpavlin@x230:~/a33$ sudo sunxi-fel read 0x42400000 0x82d0 boot1.header

# blocks and version doesn't work any more

root@x230:~# sunxi-fel -v read 0x43000000 0x20000 script.bin 

# also doesn't transfer anything and hangs


.pre

^^ extract data from device

.pre
dpavlin@klin:/klin/armbian/sunxi-tools$ make CROSS_COMPILE=arm-linux-gnueabihf- sunxi-meminfo
arm-linux-gnueabihf-gcc -std=c99 -Wall -Wextra -Wno-unused-result -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE -Iinclude/ -static  -o sunxi-meminfo meminfo.c
dpavlin@klin:/klin/armbian/sunxi-tools$ make CROSS_COMPILE=arm-linux-gnueabihf- sunxi-script_extractor
arm-linux-gnueabihf-gcc -std=c99 -Wall -Wextra -Wno-unused-result -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE -Iinclude/ -static  -o sunxi-script_extractor script_extractor.c

# put files in /cache/ instead of /sdcard/ since /sdcard/ doesn't have executable permission
dpavlin@x230:/mnt/klin/klin/armbian/sunxi-tools$ adb push sunxi-script_extractor /cache/
[100%] /cache/sunxi-script_extractor
dpavlin@x230:/mnt/klin/klin/armbian/sunxi-tools$ adb push sunxi-meminfo /cache/
[100%] /cache/sunxi-meminfo

root@astar-ococci:/cache # ./sunxi-meminfo                                     
Error: unknown or unhandled Soc: 0x1667
255|
# urgh!

svroot@astar-ococci:/cache # ./sunxi-script_extractor > a33.bin                  
root@astar-ococci:/cache # ls -al a33.bin                                      
-rw-rw-rw- root     root       131072 2017-10-18 17:57 a33.bin




.pre

^^ u-boot

.pre
dpavlin@klin:/klin/u-boot$ git remote -v
sunxi   git://git.denx.de/u-boot-sunxi.git (fetch)
sunxi   git://git.denx.de/u-boot-sunxi.git (push)

dpavlin@klin:/klin/u-boot$ git checkout -b sunxi/next sunxi/next
Branch 'sunxi/next' set up to track remote branch 'next' from 'sunxi'.
Switched to a new branch 'sunxi/next'

dpavlin@klin:/klin/u-boot$ make CROSS_COMPILE=arm-linux-gnueabihf- q8_a33_tablet_1024x600_defconfig

dpavlin@klin:/klin/u-boot$ make CROSS_COMPILE=arm-linux-gnueabihf- -j4

.pre

* http://linux-sunxi.org/FEL/USBBoot

^ malware pre-installed

* com.adups.fota
over the years, I accumulated few thinkpads, so here are some relative measurements between them

^ T22

^ T42

.pre
t42:~# cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 13
model name      : Intel(R) Pentium(R) M processor 1.60GHz
stepping        : 6
microcode       : 0x18
cpu MHz         : 600.000
cache size      : 2048 KB
fdiv_bug        : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr mce cx8 sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe bts est tm2
bogomips        : 1196.15
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 32 bits virtual
power management:

t42:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   1232 MB in  2.00 seconds = 616.23 MB/sec
 Timing buffered disk reads: 100 MB in  3.02 seconds =  33.09 MB/sec



.pre
{image: GPIO 2.png}

Lamobo/BananaPi R1

http://linux-sunxi.org/Lamobo_R1

{toc: }

^ switch connects all ports on boot

https://github.com/armbian/build/issues/511#issuecomment-258647387

^^ DSA config on armbian for r1

* https://github.com/armbian/build/issues/511

^ uart

Connect your UART adapter here:

UART0-RX: J13-P01
UART0-TX: J13-P02
GND: J12-P08

.pre
                          GND TX RX
             J12   o  o  o  o  o  o
{SD slot}          o  o  o  o

.pre

^ switch

https://www.mail-archive.com/netdev@vger.kernel.org/msg150526.html

^^ port mirroring

https://www.mail-archive.com/netdev@vger.kernel.org/msg150526.html

.pre
# ingress
      tc qdisc  add dev eth1 handle ffff: ingress
      tc filter add dev eth1 parent ffff:           \
               matchall skip_sw                      \
               action mirred egress mirror           \
               dev eth2
# egress
      tc qdisc add dev eth1 handle 1: root prio
      tc filter add dev eth1 parent 1:               \
               matchall skip_sw                       \
               action mirred egress mirror            \
               dev eth2
.pre

^ usb otg

http://git.rot13.org/?p=usb-otg;a=summary

^ usbproxy

make sure that there are no other usb modules loaded (libcomposite or g_*)

^^ mitm usb otg machine

.pre
dpavlin@r1:~/USBProxy$ git remote -v
origin  https://github.com/dominicgs/USBProxy (fetch)
origin  https://github.com/dominicgs/USBProxy (push)

dpavlin@r1:~/USBProxy/src/build$ sudo usb-mitm -l -v 058f -p 6387 -P PacketFilter_MassStorage
Loading plugins from /usr/local/lib/USBProxy/
vendorId=058f
productId=6387
cleaning up /tmp
removing 1
Made directory /tmp/gadget-SOOBVj for gadget
UnblockPassword=
Printing Config data
        Strings: 4
                DeviceProxy: DeviceProxy_LibUSB
                HostProxy: HostProxy_GadgetFS
                productId: 6387
                vendorId: 058f
        Vectors: 1
                Plugins:
                        PacketFilter_StreamLog
                        PacketFilter_MassStorage
Pointer: 1
                PacketFilter_StreamLog::file: 0xb6d779f0
Device: 12 01 00 02 00 00 00 40 8f 05 87 63 00 01 01 02 03 01
  Manufacturer: JetFlash
  Product:      Mass Storage Device
  Serial:       GUYOBHDU
        *Config(1): 09 02 20 00 01 01 00 80 32
                Interface(0):
                        *Alt(0): 09 04 00 00 02 08 06 50 00
                                EP(01): 07 05 01 02 00 02 00
                                EP(82): 07 05 82 02 00 02 00
HS Qualifier: 0a 06 00 02 00 00 00 40 01 00
         Config(1): 09 07 20 00 01 01 00 80 32
                Interface(0):
                        *Alt(0): 09 04 00 00 02 08 06 50 00
                                EP(01): 07 05 01 02 40 00 00
                                EP(82): 07 05 82 02 40 00 00
searching in [/tmp/gadget-SOOBVj]
Starting injector thread (14796) for [Injector].
Injector In FD[1/1]: 3
Starting setup writer thread (14799) for EP00.
Starting setup reader thread (14797) for EP00.
[80 06 00 03 00 00 ff 00]
[80 06 00 03 00 00 04 00]: 04 03 09 04
[80 06 02 03 09 04 ff 00]
[80 06 02 03 09 04 28 00]:
        28 03 4d 00 61 00 73 00 73 00 20 00 53 00 74 00 6f 00 72 00 61 00 67 00 65 00 20 00 44 00 65 00
        76 00 69 00 63 00 65 00
[80 06 01 03 09 04 ff 00]
[80 06 01 03 09 04 12 00]: 12 03 4a 00 65 00 74 00 46 00 6c 00 61 00 73 00 68 00
[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 12 00]: 12 03 47 00 55 00 59 00 4f 00 42 00 48 00 44 00 55 00
[00 09 01 00 00 00 00 00]
Opened EP01
Opened EP82
Starting writer thread (14802) for EP01.
Starting reader thread (14803) for EP82.
Starting writer thread (14804) for EP82.
Starting reader thread (14801) for EP01.
[a1 fe 00 00 00 00 01 00]
[a1 fe 00 00 00 00 00 00]
01[31]: 55 53 42 43 01 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00
CBW: (12), tag: 01 00 00 00

[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 12 00]: 12 03 47 00 55 00 59 00 4f 00 42 00 48 00 44 00 55 00
[00 09 01 00 00 00 00 00]

.pre

^^ original target device

.pre
dpavlin@nuc:~$ journalctl -t kernel -f
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: new high-speed USB device number 45 using xhci_hcd
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: New USB device found, idVendor=058f, idProduct=6387
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: Product: Mass Storage Device
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: Manufacturer: JetFlash
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: SerialNumber: GUYOBHDU
Sep 01 11:10:04 nuc kernel: usb-storage 2-4.4.2:1.0: USB Mass Storage device detected
Sep 01 11:10:04 nuc kernel: scsi host5: usb-storage 2-4.4.2:1.0

# BUT!

dpavlin@nuc:~$ sudo fdisk -l /dev/sdb
fdisk: cannot open /dev/sdb: No medium found

.pre

^ WiringPi

.pre
dpavlin@r1:~/BPI-WiringPi2$ git remote -v
lanefu  https://github.com/lanefu/WiringOtherPi (fetch)
lanefu  https://github.com/lanefu/WiringOtherPi (push)
origin  https://github.com/BPI-SINOVOIP/BPI-WiringPi2 (fetch)
origin  https://github.com/BPI-SINOVOIP/BPI-WiringPi2 (push)

dpavlin@r1:~/BPI-WiringPi2$ gpio readall
 +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 |   IN | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 |   IN | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 |   IN | 0 |  7 || 8  | 0 | IN   | TxD3     | 15  | 13  |
 |     |     |       0v |      |   |  9 || 10 | 0 | IN   | RxD3     | 16  | 14  |
 |   1 |   0 |     RxD2 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO.1   | 1   | 110 |
 |   0 |   2 |     TxD2 |   IN | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO.4   | 4   | 68  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | IN   | GPIO.5   | 5   | 71  |
 |  64 |  12 |     MOSI |   IN | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |     MISO |   IN | 0 | 21 || 22 | 0 | IN   | RTS2     | 6   | 2   |
 |  66 |  14 |     SCLK |   IN | 0 | 23 || 24 | 0 | IN   | CE0      | 10  | 67  |
 |     |     |       0v |      |   | 25 || 26 | 0 | IN   | GPIO.11  | 11  | 21  |
 |  19 |  30 |    SDA.1 |   IN | 0 | 27 || 28 | 0 | IN   | SCL.1    | 31  | 18  |
 |   7 |  21 |  GPIO.21 |   IN | 0 | 29 || 30 |   |      | 0v       |     |     |
 |   8 |  22 |  GPIO.22 |   IN | 0 | 31 || 32 | 0 | IN   | RTS1     | 26  | 200 |
 |   9 |  23 |  GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v       |     |     |
 |  10 |  24 |  GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | CTS1     | 27  | 201 |
 |  20 |  25 |  GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | TxD1     | 28  | 198 |
 |     |     |       0v |      |   | 39 || 40 | 0 | IN   | RxD1     | 29  | 199 |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+


.pre

^ TMP75

.pre
root@r1:/etc/telegraf# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

.pre

^^ userland

* https://github.com/ManuelSchneid3r/RaspberryPi/blob/master/sensors/src/tmp.c

.pre
dpavlin@r1:~$ cc tmp.c -o tmp -lm
dpavlin@r1:~$ sudo ./tmp /dev/i2c-1 0x49
21.5

.pre

^^ kernel hwmomn lm75 driver

.pre
root@r1:~# echo lm75 0x49 > /sys/bus/i2c/devices/i2c-1/new_device 

root@r1:~# dmesg | tail -2
[68352.599623] lm75 1-0049: hwmon1: sensor 'lm75'
[68352.599719] i2c i2c-1: new_device: Instantiated device lm75 at 0x49

root@r1:/sys/bus/i2c/devices/i2c-1# sensors
sun4i_ts-isa-0000
Adapter: ISA adapter
SoC temperature:  +44.4°C  

lm75-i2c-1-49
Adapter: mv64xxx_i2c adapter
temp1:        +22.0°C  (high = +80.0°C, hyst = +75.0°C)
.pre

^ network performance

^^ kernel 3.4

.pre
root@r1:~# uname -a
Linux r1 3.4.113-sun7i #23 SMP PREEMPT Wed Jun 14 23:57:45 CEST 2017 armv7l GNU/Linux

root@r1:~# iperf3 --reverse --client nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[  4] local 192.168.3.238 port 58203 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   107 MBytes   897 Mbits/sec                  
[  4]   1.00-2.00   sec   110 MBytes   923 Mbits/sec                  
[  4]   2.00-3.00   sec   111 MBytes   935 Mbits/sec                  
[  4]   3.00-4.00   sec   107 MBytes   894 Mbits/sec                  
[  4]   4.00-5.00   sec   111 MBytes   927 Mbits/sec                  
[  4]   5.00-6.00   sec   110 MBytes   922 Mbits/sec                  
[  4]   6.00-7.00   sec   111 MBytes   928 Mbits/sec                  
[  4]   7.00-8.00   sec   111 MBytes   935 Mbits/sec                  
[  4]   8.00-9.00   sec   111 MBytes   928 Mbits/sec                  
[  4]   9.00-10.00  sec   111 MBytes   931 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.08 GBytes   924 Mbits/sec  147             sender
[  4]   0.00-10.00  sec  1.07 GBytes   922 Mbits/sec                  receiver

iperf Done.

root@r1:~# iperf3 --client nuc
Connecting to host nuc, port 5201
[  4] local 192.168.3.238 port 58205 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  51.3 MBytes   428 Mbits/sec    0    239 KBytes       
[  4]   1.00-2.01   sec  52.5 MBytes   436 Mbits/sec    0    240 KBytes       
[  4]   2.01-3.02   sec  52.5 MBytes   436 Mbits/sec    0    245 KBytes       
[  4]   3.02-4.01   sec  50.0 MBytes   424 Mbits/sec    0    246 KBytes       
[  4]   4.01-5.02   sec  51.2 MBytes   429 Mbits/sec    0    247 KBytes       
[  4]   5.02-6.02   sec  52.5 MBytes   439 Mbits/sec    0    250 KBytes       
[  4]   6.02-7.03   sec  51.2 MBytes   427 Mbits/sec    0    253 KBytes       
[  4]   7.03-8.00   sec  48.8 MBytes   418 Mbits/sec    0    256 KBytes       
[  4]   8.00-9.02   sec  52.5 MBytes   432 Mbits/sec    0    256 KBytes       
[  4]   9.02-10.01  sec  51.2 MBytes   435 Mbits/sec    0    256 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.01  sec   514 MBytes   431 Mbits/sec    0             sender
[  4]   0.00-10.01  sec   514 MBytes   431 Mbits/sec                  receiver
.pre

^^ kernel 4.13

.pre
root@r1:~# uname -a
Linux r1 4.13.10-sunxi #57 SMP Mon Oct 30 00:08:27 CET 2017 armv7l GNU/Linux

root@r1:~# iperf3 --client nuc
Connecting to host nuc, port 5201
[  4] local 192.168.3.238 port 59520 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  67.9 MBytes   567 Mbits/sec    0    765 KBytes       
[  4]   1.00-2.01   sec  82.1 MBytes   687 Mbits/sec    0    840 KBytes       
[  4]   2.01-3.01   sec  65.7 MBytes   547 Mbits/sec    0   1.13 MBytes       
[  4]   3.01-4.02   sec  80.0 MBytes   669 Mbits/sec    0   1.13 MBytes       
[  4]   4.02-5.00   sec  76.2 MBytes   648 Mbits/sec    0   1.24 MBytes       
[  4]   5.00-6.00   sec  81.2 MBytes   681 Mbits/sec    0   1.24 MBytes       
[  4]   6.00-7.06   sec  82.5 MBytes   656 Mbits/sec    0   1.33 MBytes       
[  4]   7.06-8.00   sec  80.0 MBytes   712 Mbits/sec    0   1.33 MBytes       
[  4]   8.00-9.00   sec  78.8 MBytes   659 Mbits/sec    0   1.61 MBytes       
[  4]   9.00-10.00  sec  83.8 MBytes   702 Mbits/sec    0   2.08 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec   778 MBytes   653 Mbits/sec    0             sender
[  4]   0.00-10.00  sec   775 MBytes   650 Mbits/sec                  receiver

iperf Done.

root@r1:~# iperf3 --reverse --client nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[  4] local 192.168.3.238 port 59524 connected to 192.168.3.40 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  98.0 MBytes   822 Mbits/sec                  
[  4]   1.00-2.00   sec   112 MBytes   933 Mbits/sec                  
[  4]   2.00-3.00   sec   107 MBytes   904 Mbits/sec                  
[  4]   3.00-4.00   sec   107 MBytes   898 Mbits/sec                  
[  4]   4.00-5.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   5.00-6.00   sec   108 MBytes   903 Mbits/sec                  
[  4]   6.00-7.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   7.00-8.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   8.00-9.00   sec   108 MBytes   904 Mbits/sec                  
[  4]   9.00-10.00  sec   107 MBytes   899 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.05 GBytes   900 Mbits/sec   69             sender
[  4]   0.00-10.00  sec  1.05 GBytes   898 Mbits/sec                  receiver


.pre
* http://www.psoctools.org/
* http://dmitry.gr/index.php?r=05.Projects&proj=23.%20PSoC4
{toc: }

^ documentation

* https://www.turris.cz/doc/en/start

^^ reset modes

https://www.turris.cz/doc/en/howto/omnia_factory_reset

 Available reset modes:

    1 LED: Standard (re)boot
    2 LEDs: Rollback to latest snapshot
    3 LEDs: Rollback to factory reset
    4 LEDs: Re-flash router from flash drive
    5 LEDs or more: Boot to rescue shell

^ vlan

* https://www.turris.cz/doc/en/howto/vlan_settings_omnia

^ GPIO pinout

{image: omnia-pin-header.png}

^^ PWM same on all pins

* https://forum.turris.cz/t/gpio-documentation/2869/5

^ Debian

* https://github.com/tmshlvck/omnia-debian/wiki
* https://wiki.debian.org/InstallingDebianOn/TurrisOmnia

.pre
root@turris:/mnt/tmp# wget http://aule.elfove.cz/~brill/omnia-debian/omnia-medkit-20170330.tar.gz

# boot into rescue mode

root@(none):~# mount /dev/mmcblk0p1 /target/

root@(none):~# btrfs subvolume create /target/@debian

.pre

watchdog will timeout, but you will eventually have subvolume visible from u-boot (which is not case if you just create subvolume from Turris OS

.pre

root@turris:/# btrfs sub create @debian
Create subvolume './@debian'

root@turris:/# cd /@debian
root@turris:/@debian# tar xf /mnt/tmp/omnia-medkit-20170330.tar.gz 
root@turris:/@debian# btrfs fi df .
System, single: total=32.00MiB, used=4.00KiB
Data+Metadata, single: total=3.68GiB, used=2.25GiB
GlobalReserve, single: total=48.00MiB, used=0.00B

root@turris:/@debian# vi etc/network/interfaces
auto br0
iface br0 inet static
        bridge_ports wlan0 eth0 eth2
        address 192.168.3.254
        netmask 255.255.255.0
        gateway 192.168.3.1
root@turris:~# echo b > /proc/sysrq-trigger
[54760.278340] sysrq: SysRq : Resetting
[54760.282039] CPU1: stopping
   
U-Boot SPL 2015.10-rc2 (Aug 18 2016 - 20:43:35)
High speed PHY - Version: 2.0
SERDES0 card detect: NONE
   
Initialize Turris board topology
Detected Device ID 6820
board SerDes lanes topology details:
 | Lane #  | Speed |  Type       |
 --------------------------------
 |   0    |  5   |  PCIe0       |
 |   1    |  5   |  USB3 HOST0  |
 |   2    |  5   |  PCIe1       |
 |   3    |  5   |  USB3 HOST1  |
 |   4    |  5   |  PCIe2       |
 |   5    |  0   |  SGMII2      |
 --------------------------------
poll_op_execute: TIMEOUT
PCIe, Idx 0: detected no link
PCIe, Idx 1: detected no link
PCIe, Idx 2: detected no link
High speed PHY - Ended Successfully
DDR3 Training Sequence - Ver TIP-1.29.0
Memory config in EEPROM: 0x01
DDR3 Training Sequence - Switching XBAR Window to FastPath Window
DDR3 Training Sequence - Ended Successfully

   
U-Boot 2015.10-rc2 (Aug 18 2016 - 20:43:35 +0200), Build: jenkins-omnia-master-23
   
SoC:   MV88F6820-A0
       Watchdog enabled
I2C:   ready
SPI:   ready
DRAM:  1 GiB (ECC not enabled)
Enabling Armada 385 watchdog.
Disabling MCU startup watchdog.
Regdomain set to **
MMC:   mv_sdh: 0
SF: Detected S25FL164K with page size 256 Bytes, erase size 64 KiB, total 8 MiB
*** Warning - bad CRC, using default environment
   
Model: Marvell Armada 385 GP
Board: Turris Omnia SN: 0000000B0000B8E5
Regdomain set to **
SCSI:  MVEBU SATA INIT
SATA link 0 timeout.
SATA link 1 timeout.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
Net:   neta2
Hit any key to stop autoboot:  0
=> 

=> setenv debbootargs earlyprintk console=ttyS0,115200 rootfstype=btrfs rootwait root=/dev/mmcblk0p1 rootflags=subvol=@debian,commit=5 rw
=> setenv debboot 'setenv bootargs "$debbootargs cfg80211.freg=$regdomain"; btrload mmc 0 0x01000000 boot/vmlinuz @debian; btrload mmc 0 0x02000000 boot/dtb @debian; btrload mmc 0 0x03000000 boot/initrd.img @debian; bootz 0x01000000 0x03000000:$filesize 0x02000000'
=> saveenv
Saving Environment to SPI Flash...
SF: Detected S25FL164K with page size 256 Bytes, erase size 64 KiB, total 8 MiB
Erasing SPI flash...Writing to SPI flash...done

=> setenv defbootcmd "$bootcmd"
=> setenv debbootcmd 'i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; if test $rescue -ge 2; then echo BOOT RESCUE; run rescueboot; else if test $rescue -ge 1; then echo BOOT eMMC TurrisOS FS; run mmcboot; else echo BOOT eMMC Debian FS; run debboot; fi; fi'
=> setenv bootcmd "$debbootcmd"
=> saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done




.pre
Tehnicolor cable modem

{toc: }

http://192.168.100.1/
user: (blank)
password: admin

telnet 192.168.100.1
login: webstar
password: webstar

telnet 192.168.0.10
login: root
password: admin

^ serial

http://www.boards.ie/vbulletin/showthread.php?p=88976002#post88976002

^ snmp

http://blog.vucica.net/2014/01/few-notes-on-upc-irelands-technicolor-tc7200.html

.pre
# modem mode (not a router, wifi doesn't work!)

snmpset -v2c -c public 192.168.100.1 1.3.6.1.4.1.4413.2.2.2.1.7.1.1.0 i 1
.pre
D54250WKYXH
19V - 3.42A
04/2014

{toc}

https://downloadcenter.intel.com/product/76977/Intel-NUC-Kit-D54250WYK

^ bios

https://downloadcenter.intel.com/download/23607

current: WYLPT10H.86A.0021.2013.1017.1606
i5-4250U @ 1.30GHz

make sure that usb keychain you are using with F7 bios update option has GPT partition table on it!

.pre
dpavlin@x200:~$ sudo gdisk -l /dev/sdc
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdc: 3948544 sectors, 1.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 7564450A-7BE4-41EA-90E3-809C8C50BE51
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3948510
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         3948510   1.9 GiB     0700  Microsoft basic data
.pre

^ headers

* http://www.legitreviews.com/intel-nuc-kit-d54250wyk-review-the-nuc-gets-haswell-power_124251/2

^ sensors

.pre
dpavlin@nuc:~$ grep nct /etc/modules
nct6775

dpavlin@nuc:~$ sensors


nct6776-isa-0a00
Adapter: ISA adapter
Vcore:          +1.77 V  (min =  +0.00 V, max =  +1.74 V)  ALARM
in1:            +1.35 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:           +3.34 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
+3.3V:          +3.34 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in4:            +1.01 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:            +0.00 V  (min =  +0.00 V, max =  +0.00 V)
in6:            +0.24 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:           +3.33 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
Vbat:           +3.20 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
fan1:             0 RPM  (min =    0 RPM)
fan2:          3183 RPM  (min =    0 RPM)
fan3:             0 RPM  (min =    0 RPM)
SYSTIN:        +123.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = CPU diode
CPUTIN:         +37.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = CPU diode
AUXTIN:         +41.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = CPU diode
PECI Agent 0:   +40.0°C  (high = +80.0°C, hyst = +75.0°C)
                         (crit = +100.0°C)
PCH_CHIP_TEMP:   +0.0°C  (high = +80.0°C, hyst = +75.0°C)
PECI Agent 1:    +0.0°C  (high = +80.0°C, hyst = +75.0°C)
                         (crit =  +0.0°C)
PCH_CPU_TEMP:    +0.0°C  
intrusion0:    OK
intrusion1:    OK
beep_enable:   disabled

acpitz-virtual-0
Adapter: Virtual device
temp1:        +27.8°C  (crit = +105.0°C)
temp2:        +29.8°C  (crit = +105.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +42.0°C  (high = +100.0°C, crit = +100.0°C)
Core 0:        +42.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:        +39.0°C  (high = +100.0°C, crit = +100.0°C)
.pre