XO 4 Hardware peek and poke: Difference between revisions
(First save, not yet finished) |
No edit summary |
||
Line 1: | Line 1: | ||
Remember the BASIC peek() and poke() commands ? Hardware debugging frequently needs such an interface, and one is built into the [[XO-4]] laptop. |
Remember the BASIC peek() and poke() commands ? Hardware debugging frequently needs such an interface, and one is built into the [[XO-4]] laptop at many levels. |
||
=Introduction= |
=Introduction= |
||
While peek() and poke() exposed the raw machine, the rest of BASIC is best forgotten. |
While peek() and poke() exposed the raw machine, the rest of BASIC is best forgotten. |
||
The forth language provides an ideal low-overhead interpreter for hardware debugging, and much of the XO hardware debugging involved working in the XO laptop's native [[Open Firmware]] over a serial console |
The forth language provides an ideal low-overhead interpreter for hardware debugging, and much of the XO hardware debugging involved working in the XO laptop's native [[Open Firmware]], sometimes over a [[Serial_Adapter|serial console]]. |
||
This page discusses a method for playing around with the bare metal in Forth on the [[XO-4]] laptop while simultaneously running other applications in Linux. |
|||
While this discussion is only correct for the [[XO-4]] laptop, most of it applies verbatim to the [[XO-1.75]] laptop and with some modifications to [[XO-1.5]] |
|||
==sdkit== |
==sdkit== |
||
Line 16: | Line 15: | ||
ok |
ok |
||
Much more information about using sdkit |
Much more information about using sdkit (including installing it on systems where it isn't already available) is found in [[Forth Lesson 22]]. |
||
=XO-4 HDMI Registers= |
=XO-4 HDMI Registers= |
||
In order to access hardware registers such as the HDMI controller, you first need to map a range of the physical address space into the virtual address space used within sdkit: |
In order to access hardware registers such as the HDMI controller, you first need to map a range of the physical address space into the virtual address space used within sdkit: |
||
ok D420.B000 1000 mmap constant hdmi-base |
|||
ok hdmi-base c08 + l@ . / reads the 32b contents of HDMI_PHY_CFG0 at D420.BC08 and prints them |
|||
To modify a register, for example setting bit 1, simply: |
|||
ok hdmi-base c08 + dup l@ 2 or l! |
|||
==New to Forth ?== |
|||
You should spend ten minutes reading [[Forth Lesson 0]] and [[Forth Lesson 1]]. |
|||
[[Category:Hardware]] |
[[Category:Hardware]] |
Revision as of 04:44, 18 July 2013
Remember the BASIC peek() and poke() commands ? Hardware debugging frequently needs such an interface, and one is built into the XO-4 laptop at many levels.
Introduction
While peek() and poke() exposed the raw machine, the rest of BASIC is best forgotten. The forth language provides an ideal low-overhead interpreter for hardware debugging, and much of the XO hardware debugging involved working in the XO laptop's native Open Firmware, sometimes over a serial console. This page discusses a method for playing around with the bare metal in Forth on the XO-4 laptop while simultaneously running other applications in Linux.
sdkit
On OLPC OS builds, a Forth interpreter (sdkit) capable of accessing the hardware is available in /runin/sdkit-arm. It can be started from a Terminal:
$ su # cd /runin/sdkit-arm # RUNIN_PATH=/runin ./sdkit.sh ok
Much more information about using sdkit (including installing it on systems where it isn't already available) is found in Forth Lesson 22.
XO-4 HDMI Registers
In order to access hardware registers such as the HDMI controller, you first need to map a range of the physical address space into the virtual address space used within sdkit:
ok D420.B000 1000 mmap constant hdmi-base ok hdmi-base c08 + l@ . / reads the 32b contents of HDMI_PHY_CFG0 at D420.BC08 and prints them
To modify a register, for example setting bit 1, simply:
ok hdmi-base c08 + dup l@ 2 or l!
New to Forth ?
You should spend ten minutes reading Forth Lesson 0 and Forth Lesson 1.