Linux: Difference between revisions

From Hackspire
Jump to navigation Jump to search
No edit summary
 
(41 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page documents the Linux port to the Nspire calculator.
This page documents the Linux port to the Nspire calculator. There are currently two versions available on the TI-Nspire. All new development will occur on the new kernel however, the legacy kernel is easier to get going.


==Status==
==Booting==
 
To have something useful running using Linux on the calculator, a bootloader, kernel and rootfs is needed.


===Clickpad===
===Bootloader===
 
Source code: [https://github.com/tangrs/nspire-linux-loader2 On github]
 
Nightly builds: None.
 
Binary: [http://tiplanet.org/nspire-linux-builds/linuxloader2.tns TI-Planet]
 
The bootloader is run from the Nspire OS to load everything into memory and execute the kernel.
 
Usage instructions can be found in the [https://github.com/tangrs/nspire-linux-loader2/blob/master/README.md readme]
 
  Copy linuxloader.tns to your calculator and run it.
 
  Valid commands are:
 
      kernel <filename>: Loads a kernel image into memory
      initrd <filename>: Loads a ramdisk into memory
      dtb <filename>: Loads a DTB image into memory
      dump: Prints out the current internal state of the bootloader. Useful for
  debugging.
      free: Prints out the total amount of memory provided to the bootloader by
  the Nspire OS and amounts used by the kernel and ramdisks.
      cmdline [str]: Get/set the kernel command line parameters.
      mach [id]: Get/set the machine ID that will be provided to Linux upon
  booting. Useful for overriding the builtin default value without having to
  recompile.
      phys [<start> <size>]: Get/set the address and size of physical memory.
  Useful for overriding the builtin default value without having to recompile.
      rdsize [size]: Get/set the size of the ramdisk that Linux should create on
  boot. Leave at 0x0 for the kernel default.
      probemem: If this is run on an calculator model that isn't directly
  supported by the bootloader, you can use this to try and guess how much memory
  the system has.
      poke <addr> <value>: Write a word to an arbitrary location in the memory
  address space.
      peek <addr>: Read a word from an arbitrary location in the memory address
  space.
      boot: Boot kernel.
 
  The bootloader is also scriptable. Create a text file containing a list of
  commands to be executed and change the extension to .ll2.tns, and add the
  following line to your /documents/ndless/ndless.cfg.tns file.
 
  ext.ll2=linuxloader2
 
  Then simply open your script file and the loader will execute all the commands
  in it. A sample one could look like this:
 
  kernel linux/zImage.tns
  initrd linux/initrd.tns
  cmdline root=/dev/ram
  boot
 
  This should save a lot of typing everytime you need to boot Linux.
 
To boot the device tree (newer) kernel, ensure you add a dtb command to load the correct device tree prior to booting.
 
  kernel linux/zImage.tns
  initrd linux/initrd.tns
  dtb linux/dtb.tns
  cmdline root=/dev/ram
  boot
 
====UART====
 
You can get serial output on the UART. Remember to add <tt>,115200n8</tt> to the end of your <tt>console=</tt> command line options to keep the baud rate the same as the Nspire OS.
 
===Kernel===
 
Source code: see sections below
 
Nightly builds: [http://tiplanet.org/nspire-linux-builds/kernel.html TI-Planet]
 
Please see below sections for the differences between the legacy and newer kernels.
 
To compile the legacy kernel with default options, first clone the github repo then run:
 
  export ARCH=arm
  make nspire_defconfig
  make -j4
  cp -v arch/arm/boot/zImage /path/to/folder/zImage.tns
 
Unfortunately, the newer kernel does not have a defconfig at the moment. You have to enable options manually. Check the nightly builds for example configs you can use.
 
  export ARCH=arm
  make menuconfig
  make -j4
  make dtbs
  cp -v arch/arm/boot/zImage /path/to/folder/zImage.tns
  cp -v arch/arm/boot/dts/nspire-*.dtb /path/to/folder/
 
===Rootfs===
 
Nightly builds: [http://tiplanet.org/nspire-linux-builds/buildroot.html TI-Planet] (WIP)
 
To have programs actually run on the kernel, you need a root filesystem of some sort containing the userspace programs.
 
For testing and mucking around, a initrd should be enough. It is possible to build one using [http://buildroot.uclibc.org/ Buildroot]. Otherwise, there are a few on the nightly builds page and the Omnimaga thread.
 
For a larger root filesystem, you could put a filesystem on a USB drive and add <tt>root=/dev/sdaX</tt> to your kernel command line. You may also need to add <tt>rootdelay=10</tt> to give the USB drive time to initialize. There have also been successes running Arch Linux for ARM and Debian.
 
==Device tree kernel==
 
The newer version is a total rewrite of the original code to switch to device trees and has slightly less hardware support (but better USB support). All development in this kernel will go directly to the mainland kernel. The source code can be found at [http://kernel.org kernel.org].
 
People interested in using this branch also have to compile the device tree blobs in addition to the kernel by running:
 
  make dtbs
 
and include it in their bootscripts with:
 
  dtb linux/devicetree.tns
 
Ensure you are using a version of linuxloader2 with a build date after May 11 2013 (or commits later than 0503ca6) for stable device tree support. If your linuxloader2 does not report a build date on startup, you need to upgrade your copy. You can get an updated copy from the TI-Planet nightly builds site.
 
 
===Hardware support===


{|
{|
|-
|-
! Hardware !! Possible? !! Implemented? !! Notes
! Hardware !! Classic !! CX !! In mainline !! Notes
|-
| CPU || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| SDRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| CPU || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| SRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| SRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: yellow" | No || Matter of adding a few lines to the device tree
|-
|-
| GPIO || style="background: green; color: white" | Yes || style="background: yellow" | WIP || Vogtinator is working on it
| GPIO || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| UART1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| UART1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| UART2 || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Seems redundant
| I2C || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | WIP || Waiting to be accepted into mainline. Have not received extensive testing.
|-
|-
| Watchdog timer || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Watchdog timer || style="background: yellow" colspan="2" | Yes || style="background: yellow" | Yes || Have not tested. Just enable support for SP805 in the config
|-
|-
| RTC || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| RTC || style="background: yellow" | No || style="background: yellow" | No || style="background: yellow" | No || Should be a matter of adding a few lines to the device tree
|-
|-
| Power management || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Power management || style="background: red; color: white" | No || style="background: red; color: white" | No || style="background: red; color: white" | No || Difficult to cleanly implement
|-
|-
| Timer 1 || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Timer 1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Timer 2 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| Timer 2 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Keypad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| Keypad || style="background: green; color: white" colspan="2" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| LCD Contrast/Backlight || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
| Touchpad || style="background: green; color: white" colspan="2" | Yes || style="background: green; color: white" | WIP || Waiting to be accepted into mainline. Have not received extensive testing.
|-
|-
| TI-84 Link port || style="background: yellow" | Unknown || style="background: red; color: white" | No || Do we really need this?
| LCD Contrast/Backlight || style="background: yellow" | No || style="background: yellow" | No || style="background: yellow" | No || Should be a matter of adding a few lines to the device tree
|-  
|-  
| LED || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Weird protections stop the LED from being used so there's probably no point in implementing.
| LED || style="background: yellow" colspan="2" | WIP || style="background: yellow" | No || Unlocking the LED is already possible
|-
|-
| SPI || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| USB OTG || style="background: green; color: white" colspan="2" | Yes || style="background: green; color: white" | Yes || Everything working include seamless switching between USB host and USB device mode.
|-
|-
| USB OTG || style="background: yellow" | Difficult || style="background: red; color: white" | No || Appears to have no builtin driver
| NAND || style="background: yellow" | WIP || style="background: yellow" | WIP || style="background: yellow" | No || Dammit, why does the TI-Nspire have such weird NAND controllers to work with?
|-
|-
| USB Host || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||  
| LCD || style="background: green; color: white" colspan="2" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| NAND || style="background: yellow" | Unknown || style="background: red; color: white" | No ||
| ADC || style="background: yellow" | No || style="background: yellow" | No || style="background: yellow" | No ||  
|-
|-
| LCD || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| DES encryption/SHA generator || style="background: yellow" | No || style="background: yellow" | No || style="background: yellow" | No ||  
|-
| ADC || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
|-
| DES encryption/SHA generator || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
|-
|-
| Interrupt controller || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| Interrupt controller || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|}
|}


===Touchpad===
===Notes===


====Enabling USB OTG support====
USB OTG with seamless switching relies on a few different options in the kernel. Ensure you’ve enabled the following:
* Zevio GPIO driver - CONFIG_GPIO_ZEVIO
* USB NOP transceiver - CONFIG_NOP_USB_XCEIV
* Fixed voltage regulator driver - CONFIG_REGULATOR_FIXED_VOLTAGE
The NOP transceiver is passed onto the Chipidea driver because the TI-Nspire doesn’t need/have a PHY.
The fixed voltage regulator driver is the bridge between the GPIO and Chipidea. It controls 5V output to the USB port.
==Legacy kernel==
This kernel is not being maintained any more. All new development will occur on the new kernel. This kernel is the initial port of Linux.
===Hardware support===
====Classic====
{|
{|
|-
|-
Line 68: Line 199:
| SRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| SRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| GPIO || style="background: green; color: white" | Yes || style="background: yellow" | WIP || Vogtinator is working on it
| GPIO || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||  
|-
|-
| UART1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| UART1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| UART2 || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Seems redundant
| I2C || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Watchdog timer || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Watchdog timer || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| RTC || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| RTC || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Power management || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Power management || style="background: green; color: white" | Yes || style="background: yellow" | WIP || Basic CPU frequency scaling has been implemented
|-
|-
| Timer 1 || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Timer 1 || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
Line 86: Line 217:
| Keypad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| Keypad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Touchpad || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Vogtinator is working on it
| Touchpad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| LCD Contrast/Backlight || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
| LCD Contrast/Backlight || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
Line 92: Line 223:
| TI-84 Link port || style="background: yellow" | Unknown || style="background: red; color: white" | No || Do we really need this?
| TI-84 Link port || style="background: yellow" | Unknown || style="background: red; color: white" | No || Do we really need this?
|-  
|-  
| LED || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Weird protections stop the LED from being used so there's probably no point in implementing.
| LED || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
|-
|-
| SPI || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| SPI || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
|-
|-
| USB OTG || style="background: yellow" | Difficult || style="background: red; color: white" | No || Appears to have no builtin driver
| USB OTG || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| USB Host || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||  
| USB Host || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| NAND || style="background: yellow" | Unknown || style="background: red; color: white" | No ||
| NAND || style="background: yellow" | Unknown || style="background: red; color: white" | No ||
Line 104: Line 235:
| LCD || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| LCD || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| ADC || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
| ADC || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| DES encryption/SHA generator || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| DES encryption/SHA generator || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
Line 111: Line 242:
|}
|}


===CX===
====CX====


{|
{|
Line 123: Line 254:
| SRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| SRAM || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| GPIO || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Vogtinator is working on it
| GPIO || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||  
|-
|-
| UART1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| UART1 || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| UART2 || style="background: green; color: white" | Yes || style="background: red; color:white;" | No || Seems redundant
| I2C || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Watchdog timer || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Watchdog timer || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| RTC || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| RTC || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Power management || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Power management || style="background: green; color: white" | Yes || style="background: yellow" | WIP || Basic CPU frequency scaling has been implemented
|-
|-
| Timer 1 || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| Timer 1 || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
Line 141: Line 272:
| Keypad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| Keypad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| Touchpad || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Vogtinator is working on it
| Touchpad || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| LCD Contrast/Backlight || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
| LCD Contrast/Backlight || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| TI-84 Link port || style="background: yellow" | Unknown || style="background: red; color: white" | No || Do we really need this?
| TI-84 Link port || style="background: yellow" | Unknown || style="background: red; color: white" | No || Do we really need this?
|-
|-
| LED || style="background: green; color: white" | Yes || style="background: red; color: white" | No || Weird protections stop the LED from being used so there's probably no point in implementing.
| LED || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
|-
|-
| SPI || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| SPI || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
|-
|-
| USB OTG || style="background: yellow" | Difficult || style="background: red; color: white" | No || Appears to have no builtin driver
| USB OTG || style="background: green; color: white" | Yes || style="background: yellow" | Yes || Current implementation breaks USB Host (see notes)
|-
|-
| USB Host || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| USB Host || style="background: green; color: white" | Yes || style="background: yellow" | USB 1.1 || Uses a workaround but limits speed to USB 1.1
|-
|-
| NAND || style="background: yellow" | Unknown || style="background: red; color: white" | No ||
| NAND || style="background: green; color: white" | Yes || style="background: yellow" | WIP || Needs a lot of testing. Unstable. Note - driver for a similar chip is available [https://github.com/Xilinx/linux-xlnx/blob/master/drivers/mtd/nand/zynq_nand.c here]
|-
|-
| LCD || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
| LCD || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| ADC || style="background: green; color: white" | Yes || style="background: yellow" | Basic ||
| ADC || style="background: green; color: white" | Yes || style="background: green; color: white" | Yes ||
|-
|-
| DES encryption/SHA generator || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
| DES encryption/SHA generator || style="background: green; color: white" | Yes || style="background: red; color: white" | No ||
Line 166: Line 297:
|}
|}


==Booting==
===Quirks and technical details===


To have something useful running using Linux on the calculator, a bootloader, kernel and rootfs is needed.
====SRAM====


===Bootloader===
When needing to allocate memory from SRAM when developing for the kernel, use the following functions:


Source code: [https://github.com/tangrs/nspire-linux-loader2 On github]
  void *sram_alloc(unsigned int size, dma_addr_t *dma_addr)
  void sram_free(dma_addr_t addr, unsigned int size)


Nightly builds: [http://tangrs.id.au/linuxloader2_nightlies/ tangrs]
====Keypad====


The bootloader is run from the Nspire OS to load everything into memory and execute the kernel.
The keymaps can be found in <tt>arch/arm/mach-nspire/keypad.c</tt>. Each array element represents one bit in [[Keypads]].


Usage instructions can be found in the [https://github.com/tangrs/nspire-linux-loader2/blob/master/README.md readme]
====Touchpad====


  Copy linuxloader.tns to your calculator and run it.
There are some weird issues with the Touchpad. After booting Linux, the Touchpad doesn't function correctly under Nspire OS and requires entering diags or a few hard resets to get it back to normal. The exact cause is unknown but it is possible that this behavior is caused by the bootloader not correctly resetting Touchpad controller when the device boots up again so the Nspire OS is still using a Linux-configured Touchpad controller.
 
  Valid commands are:
 
      kernel <filename>: Loads a kernel image into memory
      initrd <filename>: Loads a ramdisk into memory
      dump: Prints out the current internal state of the bootloader. Useful for
  debugging.
      free: Prints out the total amount of memory provided to the bootloader by
  the Nspire OS and amounts used by the kernel and ramdisks.
      cmdline [str]: Get/set the kernel command line parameters.
      mach [id]: Get/set the machine ID that will be provided to Linux upon
  booting. Useful for overriding the builtin default value without having to
  recompile.
      phys [<start> <size>]: Get/set the address and size of physical memory.
  Useful for overriding the builtin default value without having to recompile.
      rdsize [size]: Get/set the size of the ramdisk that Linux should create on
  boot. Leave at 0x0 for the kernel default.
      probemem: If this is run on an calculator model that isn't directly
  supported by the bootloader, you can use this to try and guess how much memory
  the system has.
      poke <addr> <value>: Write a word to an arbitrary location in the memory
  address space.
      peek <addr>: Read a word from an arbitrary location in the memory address
  space.
      boot: Boot kernel.
 
  The bootloader is also scriptable. Create a text file containing a list of
  commands to be executed and change the extension to .ll2.tns, and add the
  following line to your /documents/ndless/ndless.cfg.tns file.
 
  ext.ll2=linuxloader2
 
  Then simply open your script file and the loader will execute all the commands
  in it. A sample one could look like this:
 
  kernel linux/zImage.tns
  initrd linux/initrd.tns
  cmdline root=/dev/ram
  boot
 
  This should save a lot of typing everytime you need to boot Linux.
 
===Kernel===
 
Source code: [https://github.com/tangrs/linux On github]
 
Nightly builds: No public nightlies yet.
 
To compile the kernel with default options, first clone the github repo then run:
 
  export ARCH=arm
  make nspire_defconfig
  make -j
  cp arch/arm/boot/zImage /path/to/folder/zImage.tns
 
===Rootfs===
 
To have programs actually run on the kernel, you need a root filesystem of some sort containing the userspace programs.
 
For testing and mucking around, a initrd should be enough. It is possible to build one using [http://buildroot.uclibc.org/ Buildroot] or look around the Omnimaga thread for a pre-built one.
 
For a larger root filesystem, you could put a filesystem on a USB drive and add <tt>root=/dev/sdaX</tt> to your kernel command line. You may also need to add <tt>rootdelay=10</tt> to give the USB drive time to initialize.
 
==Quirks and technical details==
 
===SRAM===
 
When needing to allocate memory from SRAM when developing for the kernel, use the following functions:
 
  void *sram_alloc(unsigned int size, dma_addr_t *dma_addr)
  void sram_free(dma_addr_t addr, unsigned int size)


===UART===
It has been half solved by having the Touchpad driver reset the controller on a soft reboot. However, this doesn't happen on hard reboots and will still cause the Nspire OS to not function correctly. Whenever possible, perform a soft reboot in Nspire Linux by using Ctrl+Alt(Var)+Delete(Scratchpad) or using the reboot command.


Add <tt>,115200n8</tt> to the end of your <tt>tty=</tt> command line options to keep it the same as the Nspire OS.
====LCD contrast/backlight====


===Keypad===
At the moment, contrast settings can be found at <tt>/proc/contrast</tt> for classic calculators though this will be deprecated soon. The CX already has a working driver for backlight control.


The keymaps can be found in <tt>arch/arm/mach-nspire/keypad.c</tt>. Each array element represents one bit in [[Keypads]].
====USB====


===LCD contrast/backlight===
USB support is mostly working. The only thing missing is a USB PHY driver. The USB controller driver in this kernel is currently unable to switch seamlessly between USB host and USB device mode because of this.


Contrast/Backlight settings can be found at <tt>/proc/contrast</tt> for classic calculators and <tt>/proc/backlight</tt> for CX models.
To work around this, we get the Nspire OS to set the right modes before booting Linux.


===LED===
For USB Host mode: insert a USB OTG cable's A end or a USB device into the calculator while still inside the Nspire OS before running the bootloader.


The LED has some hardware protections put on by the Nspire OS. Currently, nobody knows how to bypass this protection and we can't use it. Therefore, there's probably no reason to integrate support into the kernel.
For USB Device mode: connect the Nspire to a computer while in Nspire OS before running the bootloader.


===USB Host===
The USB hardware on the calculators also provide very little power (something in the double digit milliamps). For anything other than a basic USB drive or a keyboard, a powered USB hub might be required to supply enough power.


USB host support is very shaky. The reason why sometimes USB devices aren't recognised is probably because the USB controller isn't in the right 'mode'. Unfortunately, the method to put the controller into the right 'mode' isn't known right now.
====Extra notes for CX====


To work around this, insert a USB OTG cable's A end or a USB device into the calculator while still inside the Nspire OS before running the bootloader.
Both OTG and USB host work on the CX but since it needs a workaround that can't be integrated into the OTG driver, only one will work at a time. To maintain compatibility, the default is to use the USB host only driver. If you wish to use USB OTG on the CX, simply add <tt>cx_usb_otg</tt> to your kernel command line arguments.


===ADC===
====ADC====


ADC values can be read at <tt>/proc/adc</tt>.
ADC values can be read at <tt>/sys/bus/iio/devices/iio:device0</tt> (310 = 1V).


==More information==
==More information==


[http://www.omnimaga.org/index.php?topic=14534 Omnimaga thread]
* [http://www.omnimaga.org/ti-nspire-projects/calling-all-linux-kernel-developers! Omnimaga thread]
[http://www.omnimaga.org/index.php?topic=14534.0;msg=269335 FAQ]
* [http://www.omnimaga.org/ti-nspire-projects/calling-all-linux-kernel-developers!/msg323459/#msg323459 FAQ]
* [http://tiplanet.org/nspire-linux-builds/ TI-Planet nightly builds]
* [https://github.com/Vogtinator/nspire-linux-configs Linux configs]

Latest revision as of 10:33, 31 May 2015

This page documents the Linux port to the Nspire calculator. There are currently two versions available on the TI-Nspire. All new development will occur on the new kernel however, the legacy kernel is easier to get going.

Booting

To have something useful running using Linux on the calculator, a bootloader, kernel and rootfs is needed.

Bootloader

Source code: On github

Nightly builds: None.

Binary: TI-Planet

The bootloader is run from the Nspire OS to load everything into memory and execute the kernel.

Usage instructions can be found in the readme

 Copy linuxloader.tns to your calculator and run it.
 
 Valid commands are:
 
     kernel <filename>: Loads a kernel image into memory
     initrd <filename>: Loads a ramdisk into memory
     dtb <filename>: Loads a DTB image into memory
     dump: Prints out the current internal state of the bootloader. Useful for
 debugging.
     free: Prints out the total amount of memory provided to the bootloader by
 the Nspire OS and amounts used by the kernel and ramdisks.
     cmdline [str]: Get/set the kernel command line parameters.
     mach [id]: Get/set the machine ID that will be provided to Linux upon
 booting. Useful for overriding the builtin default value without having to
 recompile.
     phys [<start> <size>]: Get/set the address and size of physical memory.
 Useful for overriding the builtin default value without having to recompile.
     rdsize [size]: Get/set the size of the ramdisk that Linux should create on
 boot. Leave at 0x0 for the kernel default.
     probemem: If this is run on an calculator model that isn't directly
 supported by the bootloader, you can use this to try and guess how much memory
 the system has.
     poke <addr> <value>: Write a word to an arbitrary location in the memory
 address space.
     peek <addr>: Read a word from an arbitrary location in the memory address
 space.
     boot: Boot kernel.
 
 The bootloader is also scriptable. Create a text file containing a list of
 commands to be executed and change the extension to .ll2.tns, and add the
 following line to your /documents/ndless/ndless.cfg.tns file.
 
 ext.ll2=linuxloader2
 
 Then simply open your script file and the loader will execute all the commands
 in it. A sample one could look like this:
 
 kernel linux/zImage.tns
 initrd linux/initrd.tns
 cmdline root=/dev/ram
 boot
 
 This should save a lot of typing everytime you need to boot Linux.

To boot the device tree (newer) kernel, ensure you add a dtb command to load the correct device tree prior to booting.

 kernel linux/zImage.tns
 initrd linux/initrd.tns
 dtb linux/dtb.tns
 cmdline root=/dev/ram
 boot

UART

You can get serial output on the UART. Remember to add ,115200n8 to the end of your console= command line options to keep the baud rate the same as the Nspire OS.

Kernel

Source code: see sections below

Nightly builds: TI-Planet

Please see below sections for the differences between the legacy and newer kernels.

To compile the legacy kernel with default options, first clone the github repo then run:

 export ARCH=arm
 make nspire_defconfig
 make -j4
 cp -v arch/arm/boot/zImage /path/to/folder/zImage.tns

Unfortunately, the newer kernel does not have a defconfig at the moment. You have to enable options manually. Check the nightly builds for example configs you can use.

 export ARCH=arm
 make menuconfig
 make -j4
 make dtbs
 cp -v arch/arm/boot/zImage /path/to/folder/zImage.tns
 cp -v arch/arm/boot/dts/nspire-*.dtb /path/to/folder/

Rootfs

Nightly builds: TI-Planet (WIP)

To have programs actually run on the kernel, you need a root filesystem of some sort containing the userspace programs.

For testing and mucking around, a initrd should be enough. It is possible to build one using Buildroot. Otherwise, there are a few on the nightly builds page and the Omnimaga thread.

For a larger root filesystem, you could put a filesystem on a USB drive and add root=/dev/sdaX to your kernel command line. You may also need to add rootdelay=10 to give the USB drive time to initialize. There have also been successes running Arch Linux for ARM and Debian.

Device tree kernel

The newer version is a total rewrite of the original code to switch to device trees and has slightly less hardware support (but better USB support). All development in this kernel will go directly to the mainland kernel. The source code can be found at kernel.org.

People interested in using this branch also have to compile the device tree blobs in addition to the kernel by running:

 make dtbs

and include it in their bootscripts with:

 dtb linux/devicetree.tns

Ensure you are using a version of linuxloader2 with a build date after May 11 2013 (or commits later than 0503ca6) for stable device tree support. If your linuxloader2 does not report a build date on startup, you need to upgrade your copy. You can get an updated copy from the TI-Planet nightly builds site.


Hardware support

Hardware Classic CX In mainline Notes
CPU Yes Yes Yes
SRAM Yes Yes No Matter of adding a few lines to the device tree
GPIO Yes Yes Yes
UART1 Yes Yes Yes
I2C Yes Yes WIP Waiting to be accepted into mainline. Have not received extensive testing.
Watchdog timer Yes Yes Have not tested. Just enable support for SP805 in the config
RTC No No No Should be a matter of adding a few lines to the device tree
Power management No No No Difficult to cleanly implement
Timer 1 Yes Yes Yes
Timer 2 Yes Yes Yes
Keypad Yes Yes
Touchpad Yes WIP Waiting to be accepted into mainline. Have not received extensive testing.
LCD Contrast/Backlight No No No Should be a matter of adding a few lines to the device tree
LED WIP No Unlocking the LED is already possible
USB OTG Yes Yes Everything working include seamless switching between USB host and USB device mode.
NAND WIP WIP No Dammit, why does the TI-Nspire have such weird NAND controllers to work with?
LCD Yes Yes
ADC No No No
DES encryption/SHA generator No No No
Interrupt controller Yes Yes Yes

Notes

Enabling USB OTG support

USB OTG with seamless switching relies on a few different options in the kernel. Ensure you’ve enabled the following:

  • Zevio GPIO driver - CONFIG_GPIO_ZEVIO
  • USB NOP transceiver - CONFIG_NOP_USB_XCEIV
  • Fixed voltage regulator driver - CONFIG_REGULATOR_FIXED_VOLTAGE

The NOP transceiver is passed onto the Chipidea driver because the TI-Nspire doesn’t need/have a PHY.

The fixed voltage regulator driver is the bridge between the GPIO and Chipidea. It controls 5V output to the USB port.

Legacy kernel

This kernel is not being maintained any more. All new development will occur on the new kernel. This kernel is the initial port of Linux.

Hardware support

Classic

Hardware Possible? Implemented? Notes
CPU Yes Yes
SDRAM Yes Yes
SRAM Yes Yes
GPIO Yes Yes
UART1 Yes Yes
I2C Yes Yes
Watchdog timer Yes Yes
RTC Yes Yes
Power management Yes WIP Basic CPU frequency scaling has been implemented
Timer 1 Yes No
Timer 2 Yes Yes
Keypad Yes Yes
Touchpad Yes Yes
LCD Contrast/Backlight Yes Basic
TI-84 Link port Unknown No Do we really need this?
LED Yes No
SPI Yes No
USB OTG Yes Yes
USB Host Yes Yes
NAND Unknown No
LCD Yes Yes
ADC Yes Yes
DES encryption/SHA generator Yes No
Interrupt controller Yes Yes

CX

Hardware Possible? Implemented? Notes
CPU Yes Yes
SDRAM Yes Yes
SRAM Yes Yes
GPIO Yes Yes
UART1 Yes Yes
I2C Yes Yes
Watchdog timer Yes Yes
RTC Yes Yes
Power management Yes WIP Basic CPU frequency scaling has been implemented
Timer 1 Yes No
Timer 2 Yes Yes
Keypad Yes Yes
Touchpad Yes Yes
LCD Contrast/Backlight Yes Yes
TI-84 Link port Unknown No Do we really need this?
LED Yes No
SPI Yes No
USB OTG Yes Yes Current implementation breaks USB Host (see notes)
USB Host Yes USB 1.1 Uses a workaround but limits speed to USB 1.1
NAND Yes WIP Needs a lot of testing. Unstable. Note - driver for a similar chip is available here
LCD Yes Yes
ADC Yes Yes
DES encryption/SHA generator Yes No
Interrupt controller Yes Yes

Quirks and technical details

SRAM

When needing to allocate memory from SRAM when developing for the kernel, use the following functions:

 void *sram_alloc(unsigned int size, dma_addr_t *dma_addr)
 void sram_free(dma_addr_t addr, unsigned int size)

Keypad

The keymaps can be found in arch/arm/mach-nspire/keypad.c. Each array element represents one bit in Keypads.

Touchpad

There are some weird issues with the Touchpad. After booting Linux, the Touchpad doesn't function correctly under Nspire OS and requires entering diags or a few hard resets to get it back to normal. The exact cause is unknown but it is possible that this behavior is caused by the bootloader not correctly resetting Touchpad controller when the device boots up again so the Nspire OS is still using a Linux-configured Touchpad controller.

It has been half solved by having the Touchpad driver reset the controller on a soft reboot. However, this doesn't happen on hard reboots and will still cause the Nspire OS to not function correctly. Whenever possible, perform a soft reboot in Nspire Linux by using Ctrl+Alt(Var)+Delete(Scratchpad) or using the reboot command.

LCD contrast/backlight

At the moment, contrast settings can be found at /proc/contrast for classic calculators though this will be deprecated soon. The CX already has a working driver for backlight control.

USB

USB support is mostly working. The only thing missing is a USB PHY driver. The USB controller driver in this kernel is currently unable to switch seamlessly between USB host and USB device mode because of this.

To work around this, we get the Nspire OS to set the right modes before booting Linux.

For USB Host mode: insert a USB OTG cable's A end or a USB device into the calculator while still inside the Nspire OS before running the bootloader.

For USB Device mode: connect the Nspire to a computer while in Nspire OS before running the bootloader.

The USB hardware on the calculators also provide very little power (something in the double digit milliamps). For anything other than a basic USB drive or a keyboard, a powered USB hub might be required to supply enough power.

Extra notes for CX

Both OTG and USB host work on the CX but since it needs a workaround that can't be integrated into the OTG driver, only one will work at a time. To maintain compatibility, the default is to use the USB host only driver. If you wish to use USB OTG on the CX, simply add cx_usb_otg to your kernel command line arguments.

ADC

ADC values can be read at /sys/bus/iio/devices/iio:device0 (310 = 1V).

More information