A Linux bootloader for Nspire. Supports ATAG and DTB booting.
C Other
Latest commit ca31ca0 Jun 19, 2015 @tangrs Merge pull request #3 from Vogtinator/master
Update libfdt and support current ndless-sdk versions
Permalink
Failed to load latest commit information.
libfdt
.gitignore Update libfdt and support current ndless-sdk versions Apr 8, 2015
LICENSE add readme and license Oct 16, 2012
Makefile
README.md
atag.c Various code style fixups May 27, 2013
atag.h initial commit Oct 16, 2012
atag_tags.h initial commit Oct 16, 2012
cmd.c Remove unused function May 28, 2013
cmd.h Remove unused function May 28, 2013
common.c Fix usage of "%p" Apr 8, 2015
common.h Update libfdt and support current ndless-sdk versions Apr 8, 2015
fdt.c Various code style fixups May 27, 2013
fdt.h Various code style fixups May 27, 2013
kernel.c Various code style fixups May 27, 2013
kernel.h
load.c Various code style fixups May 27, 2013
load.h
mach.c Various code style fixups May 27, 2013
mach.h added serial number detection Oct 20, 2012
main.c
memory.c
memory.h
trap.c Allow returning from an exception Jul 14, 2013
trap.h Added traps for data and prefetch aborts for easier debugging May 11, 2013
traphandler.S Optimise trap handling assembly slightly Jul 14, 2013

README.md

TI-NSPIRE Linux In-Place Bootloader V2

In-place boot a Linux kernel from inside the Nspire operating system.

Improvements over old one

This version of the bootloader has been rewritten to be more stable, portable and flexible than the previous version.

Some big improvements include:

  • Being able to load ramdisks and kernels larger than 4MB (up to ~40MB on the CX)
  • This version does not need to relocate anything by default which means much higher stability
  • Has a shell-like interface to set options for loading
  • Scripting support
  • Cleaner and more portable code
  • Easy to port to other models

Usage

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
  • script <filename>: Loads a script file
  • 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. Any line starting with # will be considered a comment and ignored by the bootloader.

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.

Developers

I've done my best to write nice, clean code but it is always open to improvements. Here are some notes for extending the bootloader to support more commands and models.

If you're having trouble compiling, try removing -Werror from the CFLAGS.

Adding a new command

Commands are defined in cmd.c. Scroll down until you see a list of DEFINE_COMMANDs. Just follow the example to add your own.

Adding a new bootloader variable

The bootloader's internal state is stored in a struct called settings. It is defined in common.h. Feel free to add your own bootloader variables but if you do, make sure you also update the dump_settings() function in common.c so it is dumped correctly.

Porting to another calculator model

Most of the code is already portable to other calculators. The only parameters that need adjusting are the ones passed to Linux such as the amount of physical memory and machine ID.

At the moment, they are hardcoded values for the CX. Code to detect and automatically set the correct values for different models needs to be written. They can be manually overrided using mach and phys commands until proper detection is implemented.

If you're interested in writing an implementation for it, look in mach.c and implement the detect_memory() and detect_machine() functions.