Author: quozl Date: Thu Oct 25 09:30:24 2012 New Revision: 3383 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3383
Log: OLPC XO-4 - automatic reflash of Neonode touchscreen firmware, costs 276ms each boot
Added: cpu/arm/olpc/4.0/nn-version.fth cpu/arm/olpc/4.0/nn.bth cpu/arm/olpc/fetch-nn.fth cpu/arm/olpc/nnflash.fth Modified: cpu/arm/olpc/4.0/olpc.bth cpu/arm/olpc/bsl.fth cpu/arm/olpc/build-fw.fth
Added: cpu/arm/olpc/4.0/nn-version.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/4.0/nn-version.fth Thu Oct 25 09:30:24 2012 (r3383) @@ -0,0 +1,5 @@ +\ The Neonode touchscreen firmware +macro: NN_VERSION 0_0_0_5 + +\ FIXME: change in nnflash.fth too, until it knows how to read it +\ using Neonode's instructions.
Added: cpu/arm/olpc/4.0/nn.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/4.0/nn.bth Thu Oct 25 09:30:24 2012 (r3383) @@ -0,0 +1,7 @@ +purpose: Fetch the Neonode touchscreen firmware + +command: &builder &this +build-now + +fload ${BP}/cpu/arm/olpc/4.0/nn-version.fth +fload ${BP}/cpu/arm/olpc/fetch-nn.fth
Modified: cpu/arm/olpc/4.0/olpc.bth ============================================================================== --- cpu/arm/olpc/4.0/olpc.bth Thu Oct 25 09:17:51 2012 (r3382) +++ cpu/arm/olpc/4.0/olpc.bth Thu Oct 25 09:30:24 2012 (r3383) @@ -2,6 +2,7 @@
command: &builder &this in: ${BP}/cpu/arm/olpc/4.0/build/ec.img +in: ${BP}/cpu/arm/olpc/4.0/build/nn.img in: ${BP}/cpu/arm/olpc/4.0/build/fw.img in: ${BP}/cpu/arm/olpc/4.0/build/resetvec.img in: ${BP}/cpu/arm/olpc/4.0/build/mcastnand.bin @@ -154,6 +155,7 @@ " nandblaster_tx.bin" " nb_tx" $add-deflated-dropin
" ec.img" " ecimage.bin" $add-deflated-dropin + " nn.hex" " nn.hex" $add-deflated-dropin " ${BP}/clients/emacs/x86/emacs.rc" " emacs.rc" $add-deflated-dropin " ${BP}/clients/emacs/emacs.hlp" " emacs.hlp" $add-deflated-dropin " ${BP}/clients/emacs/arm/emacs" " emacs" $add-deflated-dropin
Modified: cpu/arm/olpc/bsl.fth ============================================================================== --- cpu/arm/olpc/bsl.fth Thu Oct 25 09:17:51 2012 (r3382) +++ cpu/arm/olpc/bsl.fth Thu Oct 25 09:30:24 2012 (r3383) @@ -222,7 +222,9 @@ ack? 0= abort" BSL - no ACK!" ;
+defer bsl-progress ' 2drop is bsl-progress ( offset size -- ) : rx-data-block ( adr len device-adr -- ) + dup h# 8000 - h# 8000 bsl-progress over h# 12 frame( ( adr len device-adr ) send-summed ( adr len ) \ device address dup send-summed ( adr len ) \ data length
Modified: cpu/arm/olpc/build-fw.fth ============================================================================== --- cpu/arm/olpc/build-fw.fth Thu Oct 25 09:17:51 2012 (r3382) +++ cpu/arm/olpc/build-fw.fth Thu Oct 25 09:30:24 2012 (r3383) @@ -366,6 +366,7 @@ fload ${BP}/cpu/arm/mmp2/fuse.fth [ifdef] bsl-uart-base fload ${BP}/cpu/arm/olpc/bsl.fth +fload ${BP}/cpu/arm/olpc/nnflash.fth [then]
[ifndef] virtual-mode @@ -857,6 +858,19 @@ update-ec-flash then then +[ifdef] update-nn-flash? + update-nn-flash? if + ['] ?enough-power catch ?dup if ( error ) + show-no-power + .error + ." Skipping NN reflash, not enough power" cr + d# 1000 ms + else + jots ['] jot to bsl-progress + update-nn-flash + then + then +[then] + use-screen-kbd open-hotspot
install-alarm
Added: cpu/arm/olpc/fetch-nn.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/fetch-nn.fth Thu Oct 25 09:30:24 2012 (r3383) @@ -0,0 +1,15 @@ +purpose: Common code for fetching the NN firmware + +\ The macro NN_VERSION, and optionally GET_NN, must be defined externally + +\ If there is a GET_NN macro, use it instead of fetching the released version. +" ${GET_NN}" expand$ nip [if] + " ${GET_NN}" expand$ $sh +[else] + " wget -q http://dev.laptop.org/pub/firmware/nn/zForce_Touch_Driver_OLPC_$%7BNN_VERSIO... -O nn.hex" expand$ $sh +[then] + +\ This forces the creation of an nn.log file, so we don't re-fetch nn.img +writing nn.version +" ${NN_VERSION}"n" expand$ ofd @ fputs +ofd @ fclose
Added: cpu/arm/olpc/nnflash.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/nnflash.fth Thu Oct 25 09:30:24 2012 (r3383) @@ -0,0 +1,58 @@ +\ See license at end of file +purpose: Reflash a Neonode touchscreen controller + +: get-touchscreen-version ( -- version.d ) + " /touchscreen" open-dev ( handle ) + dup 0= abort" could not open touchscreen" + " get-version" 2 pick $call-method ( handle version.d ) + >r >r close-dev r> r> ( version.d ) +; + +: nn-image$ " rom:\nn.hex" ; + +: reflash-nn ( file$ -- ) + $flash-bsl +; +: flash-nn ( "filename" -- ) safe-parse-word ?enough-power reflash-nn ; +: flash-nn! ( "filename" -- ) safe-parse-word reflash-nn ; +: nn-up-to-date? ( file$ -- flag ) + 2drop h# 0000.0000.0000.0005. \ FIXME: get version from file + get-touchscreen-version + d<= +; + +: update-nn-flash ( -- ) + nn-image$ 2dup nn-up-to-date? if + 2drop + else + reflash-nn + then +; + +: update-nn-flash? ( -- flag ) + nn-image$ nn-up-to-date? 0= +; + +\ LICENSE_BEGIN +\ Copyright (c) 2012 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END