![]() |
#1 |
meat popsicle
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 237
Karma: 441248
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
Programming PW2 using Go language
I am not sure if this will be of interest to anybody, but just in case.
It theory this should allow kindle programming that is as easy as with python and as effective as with c/c++ ![]() I have following: 1. Linaro 20140811 based cross-compiler hosted on Windows 64 bits and targeting PW2 (built with mingw, so no Cygwin or any other *nix like environment is required for development) - it could be used separately. 2. Patches and instructions on how to setup full Go cross environment on Windows targeting PW2 (that includes an ability to use cgo so full set of Go packages could be used, including for example sqllite3 native database driver). Updates 09/24/2014: I rebuilt gcc to move settings a bit closer to Amazon's original and it now should be possible to target PW1 and PW2 with the same compiler. crosstool-ng now a proper fork of 1.20.0 and leaves in separate github repo. Updates 10/01/2014: Introducing KAL - kindle auto-lists manager written in go and happily running on my device. Heavily inspired by barsanuphe work. It is work in progress, may serve as an example, but I have some plans for it ![]() Updates 10/03/2014: Changed error processing a bit to print better diagnostics, since I have seen a problem which I cannot understand or reproduce... Also kaznelson created KUAL extension which could be used for testing/cleanup. I rather prefer program to run automatically via even processing, but his extension could give you some peace of mind. Updates 10/08/2014 - installation and uninstallation packages (with KUAL extension) - here All sources are here and here Last edited by rupor; 10-08-2014 at 08:19 PM. |
![]() |
![]() |
![]() |
#2 | |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
Please do a: your-cross-gcc-name -dumpmachine and your-cross-gcc-name -v /dev/null and paste the outputs in code quotes here. ![]() you have never tried to cross-compile /dev/null before? Yes, it does something useful.) ![]() Note 1: "targeting PW2" requres more than just specifying the compiler's full name unless the compiler (and toolchain) was built specifically to default each and every option to that needed for the PW2. **and** not even Freescale's compilers come built that way. (and neither does that toolchain builder linked to in your readme.md build it that way unless it had a lot of help from yourself (which is what I am asking to see) ) - - - - - Note 2: We stress OpenSource software here - We get enough closed source software from Amazon. ![]() But I don't see the sources to armkpw2.exe Where are they if you built it yourself? If you didn't build that self-extracting *.exe yourself (you almost had to - to "target PW2") - Then please provide the link to the Linaro description page it can be downloaded from. - - - - Q: Did you refer to any of the other "Kindle Go" work on this site? Last edited by knc1; 09-18-2014 at 02:17 AM. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
|
Nice! But then, I'm a GoLang fanboy. I find it a bit difficult to interface the C world, though. I'm a bit spoiled with Lua and LuaJIT's FFI in that regard.
|
![]() |
![]() |
![]() |
#4 |
meat popsicle
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 237
Karma: 441248
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
@knc1 - do you have any reasons to doubt what I am saying?
![]() Code:
arm-mingw_kpw2-linux-gnueabi Code:
arm-mingw_kpw2-linux-gnueabi-gcc.exe: error: /dev/null: No such file or directory Using built-in specs. COLLECT_GCC=D:\gotools\armkpw2\bin\arm-mingw_kpw2-linux-gnueabi-gcc.exe COLLECT_LTO_WRAPPER=d:/gotools/armkpw2/bin/../libexec/gcc/arm-mingw_kpw2-linux-gnueabi/4.8.4/lto-wrapper.exe Target: arm-mingw_kpw2-linux-gnueabi Configured with: /home/rupor/crosstool-ng/.build/src/gcc-linaro-4.8-2014.08/configure --build=x86_64-build_pc-cygwin --host=x86_64-host_w64-mingw32 --target=arm-mingw_kpw2-linux-gnueabi --prefix=/home/rupor/x-tools/arm-mingw_kpw2-linux-gnueabi --with-sysroot=/home/rupor/x-tools/arm-mingw_kpw2-linux-gnueabi/arm-mingw_kpw2-linux-gnueabi/sysroot --enable-languages=c,c++ --with-arch=armv7-a --with-cpu=cortex-a9 --with-tune=cortex-a9 --with-fpu=neon --with-float=softfp --with-pkgversion='crosstool-NG git+-dirty - rupor' --with-bugurl=http://i1.kym-cdn.com/entries/icons/original/000/002/869/last-page-of-the-internet.jpg --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --with-gmp=/home/rupor/crosstool-ng/.build/arm-mingw_kpw2-linux-gnueabi/buildtools/complibs-host --with-mpfr=/home/rupor/crosstool-ng/.build/arm-mingw_kpw2-linux-gnueabi/buildtools/complibs-host --with-mpc=/home/rupor/crosstool-ng/.build/arm-mingw_kpw2-linux-gnueabi/buildtools/complibs-host --with-isl=/home/rupor/crosstool-ng/.build/arm-mingw_kpw2-linux-gnueabi/buildtools/complibs-host --with-cloog=/home/rupor/crosstool-ng/.build/arm-mingw_kpw2-linux-gnueabi/buildtools/complibs-host --with-libelf=/home/rupor/crosstool-ng/.build/arm-mingw_kpw2-linux-gnueabi/buildtools/complibs-host --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --disable-libstdcxx-pch --without-long-double-128 --enable-linker-build-id --with-linker-hash-style=gnu --enable-gold --disable-nls --disable-multilib --with-local-prefix=/home/rupor/x-tools/arm-mingw_kpw2-linux-gnueabi/arm-mingw_kpw2-linux-gnueabi/sysroot --enable-c99 --enable-long-long Thread model: posix gcc version 4.8.4 20140811 (prerelease) (crosstool-NG git+-dirty - rupor) The only sources of interest here are configuration settings for crosstool-ng. Those are always included with the toolchain itself as the result of the build (bin\arm-mingw_kpw2-linux-gnueabi-ct-ng.config) and in the full build.log (also available with toolchain). Patches to croostool-ng tool itself (if somebody wants to repeat torture of canadian-cross rebuilding GCC toolchain under cygwin with mingw on Windows 64) are now in github (reluctant fork) and patch to Go 1.3.1 which is submitted to Go community (https://code.google.com/p/go/issues/detail?id=8723). Everything is available on my github. I verified the results by re-writing small part of barsanuphe librarysync in Go and running it on my device. I am not aware of any other work of "Kindle Go" on this site - but will appreciate pointers. Last edited by rupor; 09-18-2014 at 08:50 AM. |
![]() |
![]() |
![]() |
#5 | |
but forgot what it's like
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | ||||
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Nope - nothing personal intended.
Building a cross-compiler is a highly technical undertaking. Having one presented (as a self-extracting binary) for public use without substantiation, only author claims, spurred the request for machine confirmation. Quote:
(Note: use the 'report post' button on your first post of this thread to ask a moderator to correct the title if you wish.) Quote:
Quote:
Acknowledgement of prior work reference (credit where credit is due) goes a long way towards getting acceptance of your own work. (Without insulting sounding questions such as mine.) Quote:
All of those specifics in the paragraph above would also be good to include in the "acknowledgements" section of your readme.md All of my comments about "acknowledgements" and "credit where credit is due" will give the world a much better impression of your work. They show you did not try to re-invent the entire wheel (which would be an unreasonable thing to attempt) but instead made a very careful and considered attempt to provide a specific tool solution. In summary: For this site - Maybe a tweak to the thread title - your choice. Our posts and replies (should) already include most of the answers to technical questions. For the world - A bit of editing of that readme.md file on the front page of your repo should gain you a larger user base outside of this site. Overall - Nice work, thanks a lot for this contribution. It is always nice to review a good contribution. - - - - Notes:
Last edited by knc1; 09-18-2014 at 09:50 AM. |
||||
![]() |
![]() |
![]() |
#7 |
meat popsicle
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 237
Karma: 441248
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
@eureka Yep, it is a bit easier on linux (you do not have to look for a bugs in Go's linker and finding suitable cross toolchain should be easier as well), however I do not want to run VM every time I am hacking something and learning how to build a complete toolchain under cygwin on Windows (which is not using cygwin at the end) has been an interesting challenge.
@knc1 I am sorry, I do not want to get into war of words here with you. Just to make sure my intentions are clear: I am not looking for any recognition of my work. I simply shared my experience in a hope that it may save people some time. This is spare time hobby - had a bit of free time. There is nothing to recognize. Surely knowledgeable people will understand that I did not do anything original, all work is purely derivative at this point and I do not see anybody in particular I have to thank for it - with exception of outstanding work of multiple individuals (you included!) who made jailbraking Kindle possible. Last edited by rupor; 09-18-2014 at 09:05 AM. |
![]() |
![]() |
![]() |
#8 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Just one Q: since you appear to be building against the lab126 kernel, did you have to mangle it in any way to get it to behave? I haven't done this in a long time (I usually fall back on the nearest long-term kernel release), but some of them needed some tinkering to behave nicely as a kernel header 'provider'
![]() As a minor nitpick, I'm partial to either good old fashioned unified diffs, or a real fork, but I find that sneaking in a tweaked third-party library/project/tool as a sub-project in a repo makes it hard to actually diff it to the upstream sources efficiently ![]() Last edited by NiLuJe; 09-18-2014 at 09:02 AM. |
![]() |
![]() |
![]() |
#9 |
meat popsicle
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 237
Karma: 441248
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
@NiLuJe - I looked at the Amazon's kernel but did not build against it. Saw no point since I was not planning to use C/C++ directly and Go is very conservative when using platform specific calls. Sorry for not being clear enough. I looked at Amazon's code to understand proper target versions and configuration settings for normal GNU sources (building C/C++ was a step - not a final result and I am not interested in using C/C++ toolchain or libraries directly). Was not planning to have crosstool there at all (did not realized the would be any interest), hence the inconvenient format of the contribution.
Last edited by rupor; 09-18-2014 at 09:20 AM. |
![]() |
![]() |
![]() |
#10 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Ah, right.
(Who? Me? Forgot to mention an important point? Yeah, it happens.) That cross-compiler was built just to build the GO project's code - - Its configuration did not include the **gcc** GO build (only c/c++). I.E: Just a "bootstrap" compiler. |
![]() |
![]() |
![]() |
#11 |
meat popsicle
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 237
Karma: 441248
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
@knc1 this is a full C/C++ compiler, not a bootstrap compiler. It also does not include Java,Fortran,Ada - does it make it a bootstrap? And it does not include Go (gccgo) for a reason - since gccgo version of supported Go language is not 1.3.1. In other words it is not latest. It is not latest even in latest "stable" GCC release 4.9.1 - and I was interested in really stable code base.
Last edited by rupor; 09-18-2014 at 10:05 AM. |
![]() |
![]() |
![]() |
#12 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
I was wondering if the stock, pre-built, linaro toolchain (Ref: https://launchpad.net/linaro-toolchain-binaries ) had the GO language enabled in its configuration.
(There was some past history on including it at that project.) Short answer: No, it doesn't, only C/C++/Fortran Short note: They also use crosstool-ng for the builds, read the topmost 'readme' green bar and grab the ct-ng at the second green bar. The long answer: Spoiler:
The major difference is that Linaro has adopted hard float (a useful thing to do with the i.MX6 VFP3 co-processor). The build in this thread is soft float. My 'ARMhf on Kindle' set of system libraries is built to be compatible, but not specificly for the i.MX6. Last edited by knc1; 09-18-2014 at 09:47 AM. |
![]() |
![]() |
![]() |
#13 | |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
Not a "bootstrap compiler" in en_GCC terms. |
|
![]() |
![]() |
![]() |
#14 |
meat popsicle
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 237
Karma: 441248
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
@knc1
No it does not. Proper Go language does not require cross C/C++ toolchain. Only if your code is using packages which are making calls via cgo interface which in many cases could be avoided. Only because I decided to use "native" sqllite3 driver cross-tool C/C++ toolchain was needed. I looked at linaro before building my own - 2 points here. First it is 32 bits hosted and I wanted 64 bits (call me nut). Second - I built softfp, not "soft float". And default setting for GOARM is 6 - not 7. It is not the same as ARMel - are you trying to confuse matters on purpose? Last edited by rupor; 09-18-2014 at 10:11 AM. |
![]() |
![]() |
![]() |
#15 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Just edited out my error about the PW1 support in my earlier post.
Sorry about that people. |
![]() |
![]() |
![]() |
Tags |
golang |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Which one are you ordering: PW2 wifi or PW2 3G | jocampo | Amazon Kindle | 37 | 08-18-2014 10:48 AM |
BASIC programming | Zeke | Deals and Resources (No Self-Promotion or Affiliate Links) | 7 | 03-30-2012 04:19 PM |
Programming Language inquiry | ugonkwocha | Calibre | 1 | 01-05-2011 08:49 AM |
Programming language code snippets in ebooks? | Connochaetes | Writers' Corner | 7 | 10-18-2010 02:43 PM |
Programming language for development | Pablo | Workshop | 35 | 09-02-2009 11:28 AM |