GP2X Booting Images


Klepto

Member
Joined
Jan 27, 2006
Messages
249
Location
Scotland
Website
Visit site
I find myself wanting to boot my own (non-linux) images on my GP2X, and was wondering what the best way to do this would be. I can generate the images already so I don't need a whole toolchain, just a method to boot them.

I have a bunch of little SD cards, so my preferred method would be to install something like art103's modified uboot, however the warning says my GP2X will be bricked if I try without posessing and understanding JTAG so I'm a little hesitant. Is the open2x u-boot any safer? Does anyone offer an installation or unbricking service in the UK?

How easy is it to load my image into RAM and boot it from within linux? I suspect the last part might be hard and involve messing with the kernel, I know it's possible. Does someone have a utility that does something like this already? I'm aware of SDK2X's trampoline and it looks like it's just the thing assuming it doesn't require elfs, but before I go ahead and install SDK2X and all it's dependencies I thought I'd ask :)
 
Trampoline should do what you want, and I think Squidge made a module which suspends Linux for spot (not certain though).

Flashing u-boot is risky regardless of whether it's the Open2x one, or the official one. Art103's bootloader is good and can boot the official firmware too, but cannot flash any official firmware beyond 1.4. I think DJWillis still will reflash broken GP2Xs for the cost of postage plus a donation to a charity (I myself have trashed u-boot when playing with art103's, but only once).

You may want to invest in JTAG regardless, it is able to download binaries to memory and execute them at any time (it allows you to control the CPU).
 
Orkie said:
Trampoline should do what you want, and I think Squidge made a module which suspends Linux for spot (not certain though).
Thanks, I'll go ahead and install.

Orkie said:
You may want to invest in JTAG regardless, it is able to download binaries to memory and execute them at any time (it allows you to control the CPU).
Yes, after reading more it seems that JTAG would be extremely useful. I assume I need a cradle (or similar cable), some software, some kind of cable connecting the cradle to my PC or perhaps a black box. Do I need the black box or does the cradle count as a JTAG adaptor? Can anyone suggest a good setup for use with ubuntu at the PC end?
 
Last edited by a moderator:
The cradle and a straight through parallel cable is fine. There are loads of different JTAG programs for Linux, though I've never really looked into it beyond restoring u-boot. Try asking on #gp2xdev on EFnet for recommendations :).
 
The difference between Trampoline and the Spot module is that the trampoline completely resets the processor, so you have to start from scratch setting up all the hardware/etc. Spot just suspends Linux, leaving all the hardware in the same state apart from disabling the mmu. I thought it was a 'cleaner' approach.

For debugging in either, it's a simple matter of creating a infinite loop in your startup code and using your jtag software to alter the PC to resume. Without Linux in the way, debugging is very easy in JTAG. Do learn about the MMU and the caches however, otherwise your program could easily run 100x slower than when in Linux.
 
Squidge said:
Do learn about the MMU and the caches however, otherwise your program could easily run 100x slower than when in Linux.
I've read over the ARM docs (and MMSP2 a while back) a couple of times, although I'm sure I'll be returning to them often. My current plan is...

1. flash battery LED
2. get serial port working
3. get MMU working

How would I boot my image using your Spot module?
 
Last edited by a moderator:
Klepto said:
Squidge said:
Do learn about the MMU and the caches however, otherwise your program could easily run 100x slower than when in Linux.
I've read over the ARM docs (and MMSP2 a while back) a couple of times, although I'm sure I'll be returning to them often. My current plan is...

1. flash battery LED
2. get serial port working
3. get MMU working

How would I boot my image using your Spot module?


HI
Here is my experience with doing, the same as you want to do (as i am writing my own OS for the gp2x ), 1. first flashing, i use "open2x" and have flash about 30 times, on about 8 differant gp2x's without a problem, i may just be lucky, i do have a BOB, but i have only used it for debugging.
I have used trampoline, but as pointed out, you need to do a lot of seting up, i also found it a bit buggy.

The way i code, is to assemble my code (as it's full ARM ASM ) with FasmARM to a "00008000.bin" file and then use "doimg.com" to convert it to a kernel.img.
With FasmARM, it's as simple as :
c:\fasmarm MyCode.asm 00008000.bin <enter>
No linking or chain's to set up, just one exe file "FasmARM.exe"

First thing to write is some Uart code, so you can debug the rest of your code, most of my debug programs on the PC side, are done with my own programs, run on my own OS.
Screen shot
http://www.dex4u.com/etc/gp2x.jpg

PS: One thing i have found with many gp2x, is the battery led flashing code, does not seem to work.
My OS will boot to a menu, that you can load program off SD etc and run them full HH mode, But on top of this, you will have a full set of built in functions to ease coding, + a built in basic interprter to help beginners.
You will also be able to still run linux, if you want.
 
Last edited by a moderator:
Dex said:
First thing to write is some Uart code, so you can debug the rest of your code, most of my debug programs on the PC side, are done with my own programs, run on my own OS.
Sounds like a good plan. I have trampoline working now, if I have problems with the battery LED I'll skip to the UART. Debugging will be so much nicer when I can read what's happening, beats the hell out of reading codes from a flashing LED. I'm currently using my own cross assembler running on gforth, it's still a WIP but it can assemble/disassemble all ARM 4 instructions so it's usable.

I've seen some of ur posts about ur OS, in some ways it sounds similar to what I want to do. Is there a webpage with more info? What kind of OS is it?
 
Last edited by a moderator:
Klepto said:
Dex said:
First thing to write is some Uart code, so you can debug the rest of your code, most of my debug programs on the PC side, are done with my own programs, run on my own OS.
Sounds like a good plan. I have trampoline working now, if I have problems with the battery LED I'll skip to the UART. Debugging will be so much nicer when I can read what's happening, beats the hell out of reading codes from a flashing LED. I'm currently using my own cross assembler running on gforth, it's still a WIP but it can assemble/disassemble all ARM 4 instructions so it's usable.

I've seen some of ur posts about ur OS, in some ways it sounds similar to what I want to do. Is there a webpage with more info? What kind of OS is it?

My ARM OS is a port of my x86 OS called "DexOS", the web site is here: http://www.dex4u.com/
And forum here: http://jas2o.forthworks.com/dexforum/index.php
 
Last edited by a moderator:
It looks nice. Do you have any libraries/drivers with it or is all the hardware access handled by the individual game?
 
Orkie said:
It looks nice. Do you have any libraries/drivers with it or is all the hardware access handled by the individual game?
Thanks.
The user programs load all the built in functions using a int 40h, which load the address into a call-table.
Example of basic DexOS program:
CODE

;=========================================================;
; asm2 01/05/06;
;---------------------------------------------------------;
; By Dex. ;
; ;
; Here is a basic DexOS program. ;
; Just prints a message and returns. ;
; To assemble use fasm as follows ;
; A:\fasm asm2.asm asm2.dex ;
;=========================================================;
use32 ; we want 32bit addressing
ORG 0x400000 ; where our program is loaded to
jmp start ; jump to the start of program.
db 'DEX1' ; DexOS checks for this, to make shore it a valid DexOS file.

msg1: db 'Hello world! ',13,0; String to print.

;----------------------------------------------------;
; Start of program. ;
;----------------------------------------------------;

start:
mov ax,18h ; load ax with the nonlinear data desetor
mov ds,ax ; move it into DS and ES
mov es,ax ; as you can not move it directly.

;----------------------------------------------------;
; Get calltable address. ;
;----------------------------------------------------;

mov edi,Functions; this is the interrupt
mov al,0 ; we use to load the Dex.inc
mov ah,0x0a ; with the address to DexOS functions.
int 40h ; int 40h = to Dos int 21h.

;----------------------------------------------------;
; Exit. ;
;----------------------------------------------------;
mov esi,msg1 ; this point's to our string.
call [PrintString]; this call the print function.
call [WaitForKeyPress]; is the wait for keypress function.
ret ; This returns to the CLI/GUI

;----------------------------------------------------;
; Data. ;
;----------------------------------------------------;

include 'Dex.inc' ; Here is where we include our "Dex.inc" file


The "Dex.inc" is layed out like this:
CODE

Functions:
CallTableAddress rd 1 ; 0.call-table address,DO NOT call as function.
Clstext rd 1 ; 1.Clears text mode screen, but leaves top 4 rows uncleared.
RealModeInt10h rd 1 ; 2.Call realmode int 10h,fill in AX,BX,CX,DX, with function number etc, be carefull may not work will all functions.
RealModeRegs rd 1 ; 3.Fills in AX,BX,CX,DX with result from above function,set CF to 1 on error.
WaitForKeyPress rd 1 ; 4.Wait for keypress,Exit: ASCII code of keypressed in AL .
KeyPressedNoWait rd 1 ; 5.If keyperssed AL=1,if no keypressed AL=0.
ExtendedMemory rd 1 ; 6.puts extended memory in eax (in KBs),puts total ram in ebx (in MB)
ConvenMemorySize rd 1 ; 7.puts conventional memory in eax (in KBs)
TextColor rd 1 ; 8.Sets the text color, Entry: AL=color.
PrintString rd 1 ; 9.prints a string,esi should point to a 0 termanated string.
PrintChar rd 1 ; 10.prints the char,in al
PrintCharCursor rd 1 ; 11.prints the char,in al and moves cursor
SetCursorPos rd 1 ; 12.Sets Cursor Pos, Entry: AL=X, AH=Y, if the X or Y is bigger than screen size, CF to 1, succes AH=0.
; LOT MORE FUNCTIONS ARE HERE:



Once the call-table is load, you just call the function, by filling regs with the right number (if needed) and calling the function
Print string example:
CODE

mov esi,string ;points to string
call [PrintString] ;call function
;some more code here

string: db "hello world!",0


NOTE: The name of function is in [ ] as we are calling the address in the var, not var its self.

Theres also load able module for drivers, which can be call by calling the module function along with its ID, which if load will return alink address in to a list of function in that module or error if not loaded.
You can also use lib in the form of .inc files or call the function with int 40h and function number.
The OS include's a full TCP/IP stack and can be use as a web server etc, if you have the right ethernet card, only RTL8139 ethernet card driver is written so far.
It's also got a fasm and FasmArm port.
I hope to port most of this to GP2X :).
 
Last edited by a moderator:
Hello
I am very interested in low level programming. I have already made few demos on the GBA in assembly using Fasm Arm. I have also written a little PC boot sector that print a text and the keyboard input.
I'd like to do make a tiny kernel for the GP2X, nothing huge just show something on the lcd screen.
Which registers do I need to setup ?
Does U boot initialize any or is it kernel's job ?
MMSP2 manual is quite complicate ...
I have compiled mkimage so I just need a binary bootable code .
 
I've written a emulator which bashes the hardware, but I don't have access to the code at the moment.

A good starting point however is to look at the MLC (Multi layer controller) registers. You'll also need the display registers and configure timing for the display.
 
Detays said:
Hello
I am very interested in low level programming. I have already made few demos on the GBA in assembly using Fasm Arm. I have also written a little PC boot sector that print a text and the keyboard input.
I'd like to do make a tiny kernel for the GP2X, nothing huge just show something on the lcd screen.
Which registers do I need to setup ?
Does U boot initialize any or is it kernel's job ?
MMSP2 manual is quite complicate ...
I have compiled mkimage so I just need a binary bootable code .
Hello
I will see what i can do to help you, but most of my work nowadays is (along with a team) porting DexOS to this
http://andahammer.com/mini3/?PHPSESSID=2065263f5c66805da6f667bb995c7401
First FasmArm is great and easy to use, so your all good there, next you need to up date u-boot with the one that lets you boot from
SD card, when you press start at bootup, next to start with you need to get "doimage" which is a program that converts a .bin file into a file that u-boot will load (if you have any problems getting let me know and i will post it).
Next i will post some example code (if anyone wants it?) to show how to load a BMP image and test for buttons pressed etc.
In this raw state without OS (linux).
The good thing about using this method is the bootloader will set most stuff up for you.
Dex.
 
Last edited by a moderator:
Thanks for the replies
you need to up date u-boot with the one that lets you boot from SD card, when you press start at bootup

I think that GP2X is able to boot from SD because that is the usual way to upgrade the firmware. Am I wrong ?

you need to get "doimage" which is a program that converts a .bin file into a file that u-boot will load
I have compiled mkimage using cygwin, this was in the Uboot's sources . It works well.
Maybe a "independent" (whithout needing cygwin.dll) version could be useful for other people.

Next i will post some example code (if anyone wants it?) to show how to load a BMP image and test for buttons pressed etc.
In this raw state without OS (linux).

Great :)

A good starting point however is to look at the MLC (Multi layer controller) registers. You'll also need the display registers and configure timing for the display.

If I don't misunderstand Chapter 14 DISPLAY CONTROLLER deals with basic hardware display setup and Chapter 15 : 2D graphic accelerator with fast rotation and blitting
but what are the differences between Chapter 13 : VIDEO POST PROCESSOR and Chapter 16 : IMAGE SIGNAL PROCESSOR?

Thanks again
 
Back
Top