XO 4 Hardware peek and poke: Difference between revisions

From OLPC
Jump to navigation Jump to search
(First save, not yet finished)
 
 
(3 intermediate revisions by the same user not shown)
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. This page discusses a method for playing around with the bare metal on the [[XO-4]] laptop while running Linux.
The [http://en.wikipedia.org/wiki/Forth_(programming_language) 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_adapters|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 is available in [[Forth_Lesson_22]].
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]]

Latest revision as of 05:12, 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.